[PATCH wireless] wifi: mwifiex: bound the RX reorder index by the window size

From
Maoyi Xie <hidden>
Date
2026-11-23 13:04:39
Also in
stable
mwifiex_11n_rx_reorder_pkt() reads and writes
tbl->rx_reorder_ptr[pkt_index] without checking pkt_index against
win_size. seq_num is a 16-bit field of the RX descriptor from the
device. If the window wraps past 4095, a seq_num above 4095 can pass
the window checks and give an index far past the array. With a one-slot
window, which a firmware BT coexistence event can set, every accepted
seq_num other than start_win indexes past the slot. A single lost or
reordered frame gives such a seq_num.

Drop a frame whose index is past the array, as for an occupied slot.

Found with a CodeQL-based static analysis tool that we are developing.
Both cases reproduce in a userspace harness under AddressSanitizer,
which reports nothing with this patch. Not tested on hardware.
Compile-tested with W=1 on next-20261116.

Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
Fixes: d219b7eb3792 ("mwifiex: handle BT coex event to adjust Rx BA window size")
Cc: <redacted>
Signed-off-by: Maoyi Xie <redacted>
---
I used an LLM to help write the harness and this patch.

nxpwifi has the same code. A patch that adds the same check there is
marked accepted in patchwork.
https://lore.kernel.org/linux-wireless/20261119095214.186808-1-guohongyu@cmss.chinamobile.com/ (local)

 drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
index 06b005525078411..54fb52be963aadd 100644
--- a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
@@ -616,6 +616,11 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
 		else
 			pkt_index = (seq_num+MAX_TID_VALUE) - start_win;
 
+		if (pkt_index >= win_size) {
+			ret = -1;
+			goto done;
+		}
+
 		if (tbl->rx_reorder_ptr[pkt_index]) {
 			ret = -1;
 			goto done;
base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
-- 
2.34.1
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help