[PATCH wireless 1/2] wifi: mwifiex: validate ext_scan buf_size against event buffer length
From: Tristan Madani
Date: Mon Nov 02 2026 - 09:13:05 EST
mwifiex_handle_event_ext_scan_report() uses the firmware-provided
buf_size to determine how much scan response data to parse, but never
checks it against the actual event buffer length. A firmware response
with an inflated buf_size causes reads past the event buffer.
Add a check that the declared buf_size plus the event header does not
exceed the event skb length before parsing scan results.
Fixes: 21f58d200388 ("mwifiex: implement extended scan feature")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
---
drivers/net/wireless/marvell/mwifiex/scan.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index bdd4b8465863b..77f55a3f9b450 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -2631,6 +2631,15 @@ int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
u8 *scan_resp = buf + sizeof(struct mwifiex_event_scan_result);
u16 scan_resp_size = le16_to_cpu(event_scan->buf_size);
+ if (sizeof(struct mwifiex_event_scan_result) + scan_resp_size >
+ adapter->event_skb->len) {
+ mwifiex_dbg(adapter, ERROR,
+ "EXT_SCAN: buf_size %u exceeds event length %u\n",
+ scan_resp_size, adapter->event_skb->len);
+ ret = -1;
+ goto check_next_scan;
+ }
+
if (num_of_set > MWIFIEX_MAX_AP) {
mwifiex_dbg(adapter, ERROR,
"EXT_SCAN: Invalid number of AP returned (%d)!!\n",
--
2.47.3