wifi: mwifiex: bound the RX reorder index by the window size
Subsystems (2)
PATCH 1/1 wifi: mwifiex: bound the RX reorder index by the window size
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.
---
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/[email protected]/
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +5 -0
@@ -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
Signature · 1 line
2.34.1