linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>,
	Luca Coelho <luciano.coelho@intel.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.12 34/39] mac80211: handle various extensible elements correctly
Date: Mon, 21 Jun 2021 13:51:50 -0400	[thread overview]
Message-ID: <20210621175156.735062-34-sashal@kernel.org> (raw)
In-Reply-To: <20210621175156.735062-1-sashal@kernel.org>

From: Johannes Berg <johannes.berg@intel.com>

[ Upstream commit 652e8363bbc7d149fa194a5cbf30b1001c0274b0 ]

Various elements are parsed with a requirement to have an
exact size, when really we should only check that they have
the minimum size that we need. Check only that and therefore
ignore any additional data that they might carry.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210618133832.cd101f8040a4.Iadf0e9b37b100c6c6e79c7b298cc657c2be9151a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/mac80211/util.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index c0fa526a45b4..b18150d36cb2 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -955,7 +955,7 @@ static void ieee80211_parse_extension_element(u32 *crc,
 
 	switch (elem->data[0]) {
 	case WLAN_EID_EXT_HE_MU_EDCA:
-		if (len == sizeof(*elems->mu_edca_param_set)) {
+		if (len >= sizeof(*elems->mu_edca_param_set)) {
 			elems->mu_edca_param_set = data;
 			if (crc)
 				*crc = crc32_be(*crc, (void *)elem,
@@ -976,7 +976,7 @@ static void ieee80211_parse_extension_element(u32 *crc,
 		}
 		break;
 	case WLAN_EID_EXT_UORA:
-		if (len == 1)
+		if (len >= 1)
 			elems->uora_element = data;
 		break;
 	case WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME:
@@ -984,7 +984,7 @@ static void ieee80211_parse_extension_element(u32 *crc,
 			elems->max_channel_switch_time = data;
 		break;
 	case WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION:
-		if (len == sizeof(*elems->mbssid_config_ie))
+		if (len >= sizeof(*elems->mbssid_config_ie))
 			elems->mbssid_config_ie = data;
 		break;
 	case WLAN_EID_EXT_HE_SPR:
@@ -993,7 +993,7 @@ static void ieee80211_parse_extension_element(u32 *crc,
 			elems->he_spr = data;
 		break;
 	case WLAN_EID_EXT_HE_6GHZ_CAPA:
-		if (len == sizeof(*elems->he_6ghz_capa))
+		if (len >= sizeof(*elems->he_6ghz_capa))
 			elems->he_6ghz_capa = data;
 		break;
 	}
@@ -1082,14 +1082,14 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 
 		switch (id) {
 		case WLAN_EID_LINK_ID:
-			if (elen + 2 != sizeof(struct ieee80211_tdls_lnkie)) {
+			if (elen + 2 < sizeof(struct ieee80211_tdls_lnkie)) {
 				elem_parse_failed = true;
 				break;
 			}
 			elems->lnk_id = (void *)(pos - 2);
 			break;
 		case WLAN_EID_CHAN_SWITCH_TIMING:
-			if (elen != sizeof(struct ieee80211_ch_switch_timing)) {
+			if (elen < sizeof(struct ieee80211_ch_switch_timing)) {
 				elem_parse_failed = true;
 				break;
 			}
@@ -1252,7 +1252,7 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 			elems->sec_chan_offs = (void *)pos;
 			break;
 		case WLAN_EID_CHAN_SWITCH_PARAM:
-			if (elen !=
+			if (elen <
 			    sizeof(*elems->mesh_chansw_params_ie)) {
 				elem_parse_failed = true;
 				break;
@@ -1261,7 +1261,7 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 			break;
 		case WLAN_EID_WIDE_BW_CHANNEL_SWITCH:
 			if (!action ||
-			    elen != sizeof(*elems->wide_bw_chansw_ie)) {
+			    elen < sizeof(*elems->wide_bw_chansw_ie)) {
 				elem_parse_failed = true;
 				break;
 			}
@@ -1280,7 +1280,7 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 			ie = cfg80211_find_ie(WLAN_EID_WIDE_BW_CHANNEL_SWITCH,
 					      pos, elen);
 			if (ie) {
-				if (ie[1] == sizeof(*elems->wide_bw_chansw_ie))
+				if (ie[1] >= sizeof(*elems->wide_bw_chansw_ie))
 					elems->wide_bw_chansw_ie =
 						(void *)(ie + 2);
 				else
@@ -1324,7 +1324,7 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 			elems->cisco_dtpc_elem = pos;
 			break;
 		case WLAN_EID_ADDBA_EXT:
-			if (elen != sizeof(struct ieee80211_addba_ext_ie)) {
+			if (elen < sizeof(struct ieee80211_addba_ext_ie)) {
 				elem_parse_failed = true;
 				break;
 			}
@@ -1350,7 +1350,7 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
 							  elem, elems);
 			break;
 		case WLAN_EID_S1G_CAPABILITIES:
-			if (elen == sizeof(*elems->s1g_capab))
+			if (elen >= sizeof(*elems->s1g_capab))
 				elems->s1g_capab = (void *)pos;
 			else
 				elem_parse_failed = true;
-- 
2.30.2


  parent reply	other threads:[~2021-06-21 17:54 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 17:51 [PATCH AUTOSEL 5.12 01/39] dmaengine: zynqmp_dma: Fix PM reference leak in zynqmp_dma_alloc_chan_resourc() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 02/39] dmaengine: stm32-mdma: fix PM reference leak in stm32_mdma_alloc_chan_resourc() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 03/39] dmaengine: xilinx: dpdma: Add missing dependencies to Kconfig Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 04/39] dmaengine: xilinx: dpdma: Limit descriptor IDs to 16 bits Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 05/39] mac80211: remove warning in ieee80211_get_sband() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 06/39] mac80211_hwsim: drop pending frames on stop Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 07/39] cfg80211: call cfg80211_leave_ocb when switching away from OCB Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 08/39] dmaengine: idxd: Fix missing error code in idxd_cdev_open() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 09/39] dmaengine: rcar-dmac: Fix PM reference leak in rcar_dmac_probe() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 10/39] dmaengine: mediatek: free the proper desc in desc_free handler Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 11/39] dmaengine: mediatek: do not issue a new desc if one is still current Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 12/39] dmaengine: mediatek: use GFP_NOWAIT instead of GFP_ATOMIC in prep_dma Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 13/39] net: ipv4: Remove unneed BUG() function Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 14/39] mac80211: drop multicast fragments Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 15/39] net: ethtool: clear heap allocations for ethtool function Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 16/39] inet: annotate data race in inet_send_prepare() and inet_dgram_connect() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 17/39] ping: Check return value of function 'ping_queue_rcv_skb' Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 18/39] net: annotate data race in sock_error() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 19/39] inet: annotate date races around sk->sk_txhash Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 20/39] net/packet: annotate data race in packet_sendmsg() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 21/39] net: phy: dp83867: perform soft reset and retain established link Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 22/39] riscv32: Use medany C model for modules Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 23/39] net: caif: fix memory leak in ldisc_open Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 24/39] bpf, selftests: Adjust few selftest outcomes wrt unreachable code Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 25/39] qmi_wwan: Do not call netif_rx from rx_fixup Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 26/39] net/packet: annotate accesses to po->bind Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 27/39] net/packet: annotate accesses to po->ifindex Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 28/39] r8152: Avoid memcpy() over-reading of ETH_SS_STATS Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 29/39] sh_eth: " Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 30/39] r8169: " Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 31/39] KVM: selftests: Fix kvm_check_cap() assertion Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 32/39] net: qed: Fix memcpy() overflow of qed_dcbx_params() Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 33/39] mac80211: reset profile_periodicity/ema_ap Sasha Levin
2021-06-21 17:51 ` Sasha Levin [this message]
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 35/39] recordmcount: Correct st_shndx handling Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 36/39] PCI: Add AMD RS690 quirk to enable 64-bit DMA Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 37/39] net: ll_temac: Add memory-barriers for TX BD access Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 38/39] net: ll_temac: Avoid ndo_start_xmit returning NETDEV_TX_BUSY Sasha Levin
2021-06-21 17:51 ` [PATCH AUTOSEL 5.12 39/39] riscv: dts: fu740: fix cache-controller interrupts Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210621175156.735062-34-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=johannes.berg@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).