public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields
@ 2026-04-15 22:23 Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 1/6] wifi: mwifiex: fix OOB write from firmware queue_index in WMM status response Tristan Madani
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

Hi Brian,

Note: this is a v2 resubmission. The original was sent via Gmail which
caused HTML rendering issues. This version uses git send-email for
proper plain-text formatting.

Six issues in mwifiex where firmware-controlled fields are used as array
indices or loop bounds without validation. Two are OOB writes, four are
OOB reads:

Proposed fixes in the following patches.

Thanks,
Tristan


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/6] wifi: mwifiex: fix OOB write from firmware queue_index in WMM status response
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
@ 2026-04-15 22:23 ` Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 2/6] wifi: mwifiex: fix OOB write from firmware TID in ADDBA response handler Tristan Madani
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

The firmware-controlled queue_index (u8) from the WMM queue status TLV
is used to index the 4-entry ac_status[] array without validation. An
out-of-range value causes out-of-bounds writes of three firmware-
controlled bytes into adjacent struct fields.

Add a bounds check before using queue_index as an array index.

Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/wmm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/wmm.c b/drivers/net/wireless/marvell/mwifiex/wmm.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/net/wireless/marvell/mwifiex/wmm.c
+++ b/drivers/net/wireless/marvell/mwifiex/wmm.c
@@ -945,6 +945,11 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv,
 				    tlv_wmm_qstatus->disabled);

+			if (tlv_wmm_qstatus->queue_index >=
+			    IEEE80211_NUM_ACS) {
+				break;
+			}
+
 			ac_status = &priv->wmm.ac_status[tlv_wmm_qstatus->
 							 queue_index];
 			ac_status->disabled = tlv_wmm_qstatus->disabled;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 2/6] wifi: mwifiex: fix OOB write from firmware TID in ADDBA response handler
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 1/6] wifi: mwifiex: fix OOB write from firmware queue_index in WMM status response Tristan Madani
@ 2026-04-15 22:23 ` Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 3/6] wifi: mwifiex: fix OOB read from firmware sta_count in station list response Tristan Madani
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

The TID value extracted from the Block Ack parameter set is a 4-bit
field (0-15), but aggr_prio_tbl[] has only 8 entries. A TID >= 8 causes
an out-of-bounds write to adjacent struct mwifiex_private fields.

Add a bounds check after extracting the TID.

Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/11n.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/11n.c b/drivers/net/wireless/marvell/mwifiex/11n.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/net/wireless/marvell/mwifiex/11n.c
+++ b/drivers/net/wireless/marvell/mwifiex/11n.c
@@ -155,6 +155,11 @@ int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
 	tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK)
 	       >> BLOCKACKPARAM_TID_POS;

+	if (tid >= MAX_NUM_TID) {
+		mwifiex_dbg(priv->adapter, ERROR,
+			    "ADDBA RSP: invalid tid %d\n", tid);
+		return -EINVAL;
+	}
 	tid_down = mwifiex_wmm_downgrade_tid(priv, tid);
 	ra_list = mwifiex_wmm_get_ralist_node(priv, tid_down, add_ba_rsp->
 		peer_mac_addr);


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 3/6] wifi: mwifiex: fix OOB read from firmware sta_count in station list response
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 1/6] wifi: mwifiex: fix OOB write from firmware queue_index in WMM status response Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 2/6] wifi: mwifiex: fix OOB write from firmware TID in ADDBA response handler Tristan Madani
@ 2026-04-15 22:23 ` Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 4/6] wifi: mwifiex: fix OOB read in scan response from mismatched TLV data sizes Tristan Madani
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

The firmware-controlled sta_count (u16) is used as an unbounded loop
counter for iterating station info entries. An inflated count drives
reads past the response buffer into kernel heap memory.

Add a check that sta_count fits within the response size.

Fixes: b21783e94e20 ("mwifiex: add sta_list firmware command")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -976,7 +976,15 @@ static int mwifiex_ret_uap_sta_list(struct mwifiex_private *priv,
 	struct mwifiex_ie_types_sta_info *sta_info = (void *)&sta_list->tlv;
 	int i;
 	struct mwifiex_sta_node *sta_node;
+	u16 resp_size = le16_to_cpu(resp->size);
+	u16 count = le16_to_cpu(sta_list->sta_count);
+	u16 max_count;

+	if (resp_size < sizeof(*resp) - sizeof(resp->params) + sizeof(*sta_list))
+		return -EINVAL;
+	max_count = (resp_size - sizeof(*resp) + sizeof(resp->params) -
+		     sizeof(*sta_list)) / sizeof(*sta_info);
+	count = min(count, max_count);
-	for (i = 0; i < (le16_to_cpu(sta_list->sta_count)); i++) {
+	for (i = 0; i < count; i++) {
 		sta_node = mwifiex_get_sta_entry(priv, sta_info->mac);
 		if (unlikely(!sta_node))
 			continue;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 4/6] wifi: mwifiex: fix OOB read in scan response from mismatched TLV data sizes
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
                   ` (2 preceding siblings ...)
  2026-04-15 22:23 ` [PATCH v2 3/6] wifi: mwifiex: fix OOB read from firmware sta_count in station list response Tristan Madani
@ 2026-04-15 22:23 ` Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 5/6] wifi: mwifiex: fix OOB read from firmware intf_num in multichannel event Tristan Madani
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

The TSF and ChanBand TLV arrays are indexed by the firmware-controlled
number_of_sets without cross-checking against the TLV header length
fields. When number_of_sets exceeds the TLV data, the loop reads past
the TLV data into adjacent command response memory.

Stop using the TLV data once the index exceeds its reported length.

Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/scan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -2188,10 +2188,12 @@ static int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
 		 * received.
 		 */
 		if (tsf_tlv)
-			memcpy(&fw_tsf, &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE],
+			if ((idx + 1) * TSF_DATA_SIZE <=
+			    le16_to_cpu(tsf_tlv->header.len))
+				memcpy(&fw_tsf, &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE],
 			       sizeof(fw_tsf));

-		if (chan_band_tlv) {
+		if (chan_band_tlv && (idx + 1) * sizeof(*chan_band) <=
+		    le16_to_cpu(chan_band_tlv->header.len)) {
 			chan_band = &chan_band_tlv->chan_band_param[idx];
 			radio_type = &chan_band->radio_type;
 		} else {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 5/6] wifi: mwifiex: fix OOB read from firmware intf_num in multichannel event
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
                   ` (3 preceding siblings ...)
  2026-04-15 22:23 ` [PATCH v2 4/6] wifi: mwifiex: fix OOB read in scan response from mismatched TLV data sizes Tristan Madani
@ 2026-04-15 22:23 ` Tristan Madani
  2026-04-15 22:23 ` [PATCH v2 6/6] wifi: mwifiex: fix OOB read from inflated TLV length in IBSS peer event Tristan Madani
  2026-04-17  0:16 ` [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Brian Norris
  6 siblings, 0 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

The firmware-controlled intf_num is used to iterate the flexible array
bss_type_numlist[] without checking it against the TLV data length. An
inflated value causes out-of-bounds reads past the TLV data.

Clamp intf_num to the available TLV data.

Fixes: 8d6b538a5eac ("mwifiex: handle multichannel event")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/sta_event.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
@@ -450,7 +450,15 @@ void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
 		grp_info = (struct mwifiex_ie_types_mc_group_info *)tlv;

 		intf_num = grp_info->intf_num;
+		{
+			u16 fixed_len = sizeof(*grp_info) -
+					sizeof(grp_info->header);
+			if (tlv_len < fixed_len ||
+			    intf_num > tlv_len - fixed_len)
+				intf_num = 0;
+		}
+
 		for (i = 0; i < intf_num; i++) {
 			bss_type = grp_info->bss_type_numlist[i] >> 4;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 6/6] wifi: mwifiex: fix OOB read from inflated TLV length in IBSS peer event
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
                   ` (4 preceding siblings ...)
  2026-04-15 22:23 ` [PATCH v2 5/6] wifi: mwifiex: fix OOB read from firmware intf_num in multichannel event Tristan Madani
@ 2026-04-15 22:23 ` Tristan Madani
  2026-04-17  0:16 ` [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Brian Norris
  6 siblings, 0 replies; 8+ messages in thread
From: Tristan Madani @ 2026-04-15 22:23 UTC (permalink / raw)
  To: Brian Norris; +Cc: Johannes Berg, linux-wireless, linux-kernel

From: Tristan Madani <tristan@talencesecurity.com>

The IBSS connected handler replaces the buffer-bounded evt_len with
the firmware-controlled TLV header length. An inflated value drives the
IE parsing loop past the event buffer into adjacent kernel heap memory.

Cap the TLV-derived length at the remaining event data size.

Fixes: 432da7d243da ("mwifiex: add HT aggregation support for adhoc mode")
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c
index XXXXXXX..XXXXXXX 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
@@ -46,6 +46,10 @@ static int mwifiex_check_ibss_peer_capabilties(struct mwifiex_private *priv,
 		evt_len = le16_to_cpu(tlv_mgmt_frame->header.len);
 		curr += (sizeof(*tlv_mgmt_frame) + 12);
+		if (evt_len > event->len -
+		    (curr - event->data))
+			evt_len = event->len -
+				  (curr - event->data);
 	} else {
 		mwifiex_dbg(priv->adapter, MSG,


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields
  2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
                   ` (5 preceding siblings ...)
  2026-04-15 22:23 ` [PATCH v2 6/6] wifi: mwifiex: fix OOB read from inflated TLV length in IBSS peer event Tristan Madani
@ 2026-04-17  0:16 ` Brian Norris
  6 siblings, 0 replies; 8+ messages in thread
From: Brian Norris @ 2026-04-17  0:16 UTC (permalink / raw)
  To: Tristan Madani; +Cc: Johannes Berg, linux-wireless, linux-kernel

On Wed, Apr 15, 2026 at 10:23:21PM +0000, Tristan Madani wrote:
> From: Tristan Madani <tristan@talencesecurity.com>
> 
> Hi Brian,
> 
> Note: this is a v2 resubmission. The original was sent via Gmail which
> caused HTML rendering issues. This version uses git send-email for
> proper plain-text formatting.

You also sent it privately / directly to me, and I don't think you even
sent the whole thing. You've fixed some of that now, thanks.

> Six issues in mwifiex where firmware-controlled fields are used as array
> indices or loop bounds without validation. Two are OOB writes, four are
> OOB reads:
> 
> Proposed fixes in the following patches.

Several of these don't actually apply to wireless/for-next correctly, so
I can't actually review them. On at least one, I think you seem to have
stripped a line or two somehow.

Please confirm you can apply your series to
git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git
for-next with 'git am', and then resend.

Brian

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-17  0:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 22:23 [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Tristan Madani
2026-04-15 22:23 ` [PATCH v2 1/6] wifi: mwifiex: fix OOB write from firmware queue_index in WMM status response Tristan Madani
2026-04-15 22:23 ` [PATCH v2 2/6] wifi: mwifiex: fix OOB write from firmware TID in ADDBA response handler Tristan Madani
2026-04-15 22:23 ` [PATCH v2 3/6] wifi: mwifiex: fix OOB read from firmware sta_count in station list response Tristan Madani
2026-04-15 22:23 ` [PATCH v2 4/6] wifi: mwifiex: fix OOB read in scan response from mismatched TLV data sizes Tristan Madani
2026-04-15 22:23 ` [PATCH v2 5/6] wifi: mwifiex: fix OOB read from firmware intf_num in multichannel event Tristan Madani
2026-04-15 22:23 ` [PATCH v2 6/6] wifi: mwifiex: fix OOB read from inflated TLV length in IBSS peer event Tristan Madani
2026-04-17  0:16 ` [PATCH v2 0/6] wifi: mwifiex: fix OOB reads and writes from firmware response fields Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox