* [PATCH wireless 0/2] wifi: mwifiex: validate firmware response sizes
@ 2026-11-02 13:59 Tristan Madani
2026-11-02 13:59 ` [PATCH wireless 1/2] wifi: mwifiex: validate ext_scan buf_size against event buffer length Tristan Madani
2026-11-02 13:59 ` [PATCH wireless 2/2] wifi: mwifiex: validate command response size against " Tristan Madani
0 siblings, 2 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-02 13:59 UTC (permalink / raw)
To: briannorris, francesco
Cc: bzhao, akarwar, linville, linux-wireless, linux-kernel, stable,
Tristan Madani
Two missing bounds checks on firmware-provided size fields in mwifiex:
1. ext_scan event: buf_size is used to determine scan response
parsing length but never checked against the event buffer.
2. command response: resp->size is passed to individual handlers
but never validated against the response skb length.
Both patches add early validation that the declared size fits within
the actual buffer before proceeding with parsing.
Tristan Madani (2):
wifi: mwifiex: validate ext_scan buf_size against event buffer length
wifi: mwifiex: validate command response size against buffer length
drivers/net/wireless/marvell/mwifiex/cmdevt.c | 14 ++++++++++++++
drivers/net/wireless/marvell/mwifiex/scan.c | 9 +++++++++
2 files changed, 23 insertions(+)
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH wireless 1/2] wifi: mwifiex: validate ext_scan buf_size against event buffer length
2026-11-02 13:59 [PATCH wireless 0/2] wifi: mwifiex: validate firmware response sizes Tristan Madani
@ 2026-11-02 13:59 ` Tristan Madani
2026-11-02 13:59 ` [PATCH wireless 2/2] wifi: mwifiex: validate command response size against " Tristan Madani
1 sibling, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-02 13:59 UTC (permalink / raw)
To: briannorris, francesco
Cc: bzhao, akarwar, linville, linux-wireless, linux-kernel, stable,
Tristan Madani
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@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
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
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH wireless 2/2] wifi: mwifiex: validate command response size against buffer length
2026-11-02 13:59 [PATCH wireless 0/2] wifi: mwifiex: validate firmware response sizes Tristan Madani
2026-11-02 13:59 ` [PATCH wireless 1/2] wifi: mwifiex: validate ext_scan buf_size against event buffer length Tristan Madani
@ 2026-11-02 13:59 ` Tristan Madani
1 sibling, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-02 13:59 UTC (permalink / raw)
To: briannorris, francesco
Cc: bzhao, akarwar, linville, linux-wireless, linux-kernel, stable,
Tristan Madani
mwifiex_process_cmdresp() reads the firmware-provided resp->size field
and passes it to individual command handlers that use it to determine
how much data to process, but never validates it against the actual
response buffer length. A firmware response with an inflated size
field causes subsequent handlers to read past the buffer.
Add a check early in command response processing that validates the
declared response size fits within the response skb.
Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/marvell/mwifiex/cmdevt.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
index 6e04d7da62179..f59b53c2e7b5f 100644
--- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
@@ -821,6 +821,20 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
orig_cmdresp_no = le16_to_cpu(resp->command);
cmdresp_no = (orig_cmdresp_no & HostCmd_CMD_ID_MASK);
+ if (le16_to_cpu(resp->size) > adapter->curr_cmd->resp_skb->len) {
+ mwifiex_dbg(adapter, ERROR,
+ "CMD_RESP: resp size %u exceeds buffer %u\n",
+ le16_to_cpu(resp->size),
+ adapter->curr_cmd->resp_skb->len);
+ if (adapter->curr_cmd->wait_q_enabled)
+ adapter->cmd_wait_q.status = -1;
+ mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd);
+ spin_lock_bh(&adapter->mwifiex_cmd_lock);
+ adapter->curr_cmd = NULL;
+ spin_unlock_bh(&adapter->mwifiex_cmd_lock);
+ return -1;
+ }
+
if (adapter->curr_cmd->cmd_no != cmdresp_no) {
mwifiex_dbg(adapter, ERROR,
"cmdresp error: cmd=0x%x cmd_resp=0x%x\n",
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-02 13:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 13:59 [PATCH wireless 0/2] wifi: mwifiex: validate firmware response sizes Tristan Madani
2026-11-02 13:59 ` [PATCH wireless 1/2] wifi: mwifiex: validate ext_scan buf_size against event buffer length Tristan Madani
2026-11-02 13:59 ` [PATCH wireless 2/2] wifi: mwifiex: validate command response size against " Tristan Madani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®