wifi: mwifiex: fix three firmware-triggered validation issues
Subsystems (2)
v2 cover wifi: mwifiex: fix three firmware-triggered validation issues
From: Tristan Madani <[email protected]>
Three validation fixes for firmware-provided data in mwifiex:
Patch 1 bounds-checks the TID extracted from ADDBA responses before indexing aggr_prio_tbl[].
Patch 2 validates intf_num in multichannel group info TLVs against the available TLV data length.
Patch 3 caps the TLV-derived length in IBSS connected events at the remaining event buffer size, with an additional guard against unsigned underflow when the fixed-size header advance overshoots the buffer.
v2:
- Patch 3: add underflow guard before computing remaining length, as pointed out by Jeff Chen: when the header advance overshoots the buffer, the unsigned subtraction wraps (Jeff Chen)
Tristan Madani (3):
wifi: mwifiex: validate TID in ADDBA response handler
wifi: mwifiex: validate intf_num in multichannel event handler
wifi: mwifiex: cap TLV length in IBSS connected event handler
drivers/net/wireless/marvell/mwifiex/11n.c | 6 ++++++ drivers/net/wireless/marvell/mwifiex/sta_event.c | 8 ++++++++ 2 files changed, 14 insertions(+)
Signature · 1 line
2.47.3
PATCH v2 1/3 wifi: mwifiex: validate TID in ADDBA response handler
From: Tristan Madani <[email protected]>
The TID value extracted from the Block Ack parameter set is a 4-bit field (0-15), but aggr_prio_tbl[] has only MAX_NUM_TID (8) entries. A value >= 8 causes an out-of-bounds array access.
Add a bounds check after extracting the TID.
--- drivers/net/wireless/marvell/mwifiex/11n.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/marvell/mwifiex/11n.c +6 -0
@@ -154,6 +154,12 @@ 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);
Signature · 1 line
2.47.3
PATCH v2 2/3 wifi: mwifiex: validate intf_num in multichannel event handler
In reply to Tristan MadaniFrom: Tristan Madani <[email protected]>
The intf_num field from the multichannel group info TLV indexes the flexible array bss_type_numlist[] without checking whether it fits the TLV data. An intf_num larger than the available data causes reads past the TLV boundary.
Add a check that intf_num does not exceed the number of entries that fit in the TLV data.
--- drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/marvell/mwifiex/sta_event.c +4 -0
@@ -450,6 +450,10 @@ 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; +if (tlv_len <sizeof (*grp_info) -sizeof (grp_info->header) || + intf_num > tlv_len - (sizeof (*grp_info) -sizeof (grp_info->header))) +break ; +for (i =0 ; i < intf_num; i++) { bss_type = grp_info->bss_type_numlist[i] >>4 ; bss_num = grp_info->bss_type_numlist[i] &BSS_NUM_MASK ;
Signature · 1 line
2.47.3
PATCH v2 3/3 wifi: mwifiex: cap TLV length in IBSS connected event handler
In reply to Tristan MadaniFrom: Tristan Madani <[email protected]>
In the IBSS connected event handler, the buffer-bounded evt_len is replaced with the TLV header length from the firmware. An inflated value drives the IE parsing loop past the event buffer.
After the fixed-size header advance, check that curr has not overshot the event data before computing the remaining length -- the subtraction wraps when curr is past the end because event->len is unsigned. Then cap the TLV-derived length at the remaining data size.
--- drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/marvell/mwifiex/sta_event.c +4 -0
@@ -45,6 +45,10 @@ static int mwifiex_check_ibss_peer_capabilities(struct mwifiex_private *priv,*/ evt_len =le16_to_cpu (tlv_mgmt_frame->header.len); curr += (sizeof (*tlv_mgmt_frame) +12 ); +if (curr > event->data + event->len) +return 0 ; +if (evt_len > event->len - (curr - event->data)) + evt_len = event->len - (curr - event->data); }else {mwifiex_dbg (priv->adapter,MSG ,"management frame tlv not found!\n" );
Signature · 1 line
2.47.3
Re: [PATCH v2 wireless 3/3] wifi: mwifiex: cap TLV length in IBSS connected event handler
From: Jeff Chen <[email protected]>
Quoted 35 lines · Tristan Madani
From: Tristan Madani <[email protected]>
In the IBSS connected event handler, the buffer-bounded
evt_lenis replaced with the TLV header length from the firmware. An inflated value drives the IE parsing loop past the event buffer.After the fixed-size header advance, check that curr has not overshot the event data before computing the remaining length -- the subtraction wraps when curr is past the end because
event->lenis unsigned. Then cap the TLV-derived length at the remaining data size.Fixes 432da7d243da ("mwifiex: add HT aggregation support for adhoc mode")Signed-off-by Tristan Madani <[email protected]>--- drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/wireless/marvell/mwifiex/sta_event.c +4
-0@@ -45,6 +45,10 @@ static int mwifiex_check_ibss_peer_capabilities(struct mwifiex_private *priv,*/ evt_len =le16_to_cpu (tlv_mgmt_frame->header.len); curr += (sizeof (*tlv_mgmt_frame) +12 ); +if (curr > event->data + event->len) +return 0 ; +if (evt_len > event->len - (curr - event->data)) + evt_len = event->len - (curr - event->data); }else {mwifiex_dbg (priv->adapter,MSG ,"management frame tlv not found!\n" );Signature · 1 line
2.47.3
Brian Norris
maintainerQuoted 15 lines · Tristan Madani
From: Tristan Madani <[email protected]>
Three validation fixes for firmware-provided data in mwifiex:
Patch 1 bounds-checks the TID extracted from ADDBA responses before indexing aggr_prio_tbl[].
Patch 2 validates
intf_numin multichannel group info TLVs against the available TLV data length.Patch 3 caps the TLV-derived length in IBSS connected events at the remaining event buffer size, with an additional guard against unsigned underflow when the fixed-size header advance overshoots the buffer.
Quoted 4 lines
v2:
- Patch 3: add underflow guard before computing remaining length, as pointed out by Jeff Chen: when the header advance overshoots the buffer, the unsigned subtraction wraps (Jeff Chen)
Please include information about how you're testing these. (You're testing this, right?)
Brian
A message that is not in the archive (sent off-list or not yet received): [email protected]
Brian Norris
maintainerPlease reply-all. And especially don't exclude the mailing list. Fixing that for you.
Quoted 8 lines · Tristan Madani
Quoted 2 lines · Brian Norris
Please include information about how you're testing these. (You're testing this, right?)
These are hardening patches for firmware-provided fields found by code inspection. Direct runtime testing would require injecting crafted firmware responses, which is not practical without a device emulator or modified firmware.
Testing is not only for the purpose of triggering your alleged security issues. It's for ensuring you don't regress real users.
If you can't be bothered to test, we can't be bothered to take your "fixes".
Brian
Sorry for the broken Cc, and thanks for fixing the threading.
Build tested with the series applied on wireless/main (v7.4-rc4), x86_64 defconfig, gcc 14.2, W=1:
make W=1 drivers/net/wireless/marvell/mwifiex/
all four modules (mwifiex, mwifiex_sdio, mwifiex_pcie, mwifiex_usb) build clean, 0 errors, 0 warnings.
I do not have mwifiex hardware for runtime testing.
Tristan