* [PATCH v2 wireless 0/2] wifi: nxpwifi: firmware response validation fixes
@ 2026-11-20 22:59 Tristan Madani
2026-11-20 22:59 ` [PATCH v2 wireless 1/2] wifi: nxpwifi: validate ext_scan buf_size against event buffer length Tristan Madani
2026-11-20 22:59 ` [PATCH v2 wireless 2/2] wifi: nxpwifi: validate command response size against " Tristan Madani
0 siblings, 2 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-20 22:59 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, linux-wireless, linux-kernel, stable, Tristan Madani
The nxpwifi driver trusts several size fields from firmware responses
without validating them against actual buffer lengths. This series
adds bounds checks to prevent reads past the buffer when firmware
provides inflated sizes.
Changes in v2:
- Dropped the HE capability TLV length patch (was 1/3), superseded by
commit f17e2eda1630a ("wifi: nxpwifi: bound the TLV lengths in the
11AX_CFG response")
- Patch 2/2: moved the response size check after timer_delete_sync()
so the command timer is properly cancelled before the early return,
as pointed out by Jeff Chen
Tristan Madani (2):
wifi: nxpwifi: validate ext_scan buf_size against event buffer length
wifi: nxpwifi: validate command response size against buffer length
drivers/net/wireless/nxp/nxpwifi/cmdevt.c | 14 ++++++++++++++
drivers/net/wireless/nxp/nxpwifi/scan.c | 9 +++++++++
2 files changed, 23 insertions(+)
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 wireless 1/2] wifi: nxpwifi: validate ext_scan buf_size against event buffer length
2026-11-20 22:59 [PATCH v2 wireless 0/2] wifi: nxpwifi: firmware response validation fixes Tristan Madani
@ 2026-11-20 22:59 ` Tristan Madani
2026-11-20 22:59 ` [PATCH v2 wireless 2/2] wifi: nxpwifi: validate command response size against " Tristan Madani
1 sibling, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-20 22:59 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, linux-wireless, linux-kernel, stable, Tristan Madani
nxpwifi_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: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
drivers/net/wireless/nxp/nxpwifi/scan.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/wireless/nxp/nxpwifi/scan.c b/drivers/net/wireless/nxp/nxpwifi/scan.c
index 4eeba6700aa72..398c3f8ec0781 100644
--- a/drivers/net/wireless/nxp/nxpwifi/scan.c
+++ b/drivers/net/wireless/nxp/nxpwifi/scan.c
@@ -2443,6 +2443,15 @@ int nxpwifi_handle_event_ext_scan_report(struct nxpwifi_private *priv,
u8 *scan_resp = buf + sizeof(struct nxpwifi_event_scan_result);
u16 scan_resp_size = le16_to_cpu(event_scan->buf_size);
+ if (sizeof(struct nxpwifi_event_scan_result) + scan_resp_size >
+ adapter->event_skb->len) {
+ nxpwifi_dbg(adapter, ERROR,
+ "EXT_SCAN: buf_size %u exceeds event length %u\n",
+ scan_resp_size, adapter->event_skb->len);
+ ret = -EINVAL;
+ goto check_next_scan;
+ }
+
if (num_of_set > NXPWIFI_MAX_AP) {
nxpwifi_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 v2 wireless 2/2] wifi: nxpwifi: validate command response size against buffer length
2026-11-20 22:59 [PATCH v2 wireless 0/2] wifi: nxpwifi: firmware response validation fixes Tristan Madani
2026-11-20 22:59 ` [PATCH v2 wireless 1/2] wifi: nxpwifi: validate ext_scan buf_size against event buffer length Tristan Madani
@ 2026-11-20 22:59 ` Tristan Madani
1 sibling, 0 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-20 22:59 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, linux-wireless, linux-kernel, stable, Tristan Madani
nxpwifi_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: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Cc: stable@vger.kernel.org
Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
---
Changes in v2:
- Move the response size check after timer_delete_sync() so the command
timer is properly cancelled before the early return (Jeff Chen)
drivers/net/wireless/nxp/nxpwifi/cmdevt.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/net/wireless/nxp/nxpwifi/cmdevt.c b/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
index fc1950a125b65..ebcfee8cb3872 100644
--- a/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
+++ b/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
@@ -732,6 +732,20 @@ int nxpwifi_process_cmdresp(struct nxpwifi_adapter *adapter)
timer_delete_sync(&adapter->cmd_timer);
clear_bit(NXPWIFI_IS_CMD_TIMEDOUT, &adapter->work_flags);
+ if (le16_to_cpu(resp->size) > adapter->curr_cmd->resp_skb->len) {
+ nxpwifi_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 = -EINVAL;
+ nxpwifi_recycle_cmd_node(adapter, adapter->curr_cmd);
+ spin_lock_bh(&adapter->nxpwifi_cmd_lock);
+ adapter->curr_cmd = NULL;
+ spin_unlock_bh(&adapter->nxpwifi_cmd_lock);
+ return -EINVAL;
+ }
+
if (adapter->curr_cmd->cmd_flag & CMD_F_HOSTCMD) {
/* Copy original response back to response buffer */
struct nxpwifi_ds_misc_cmd *hostcmd;
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-20 22:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 22:59 [PATCH v2 wireless 0/2] wifi: nxpwifi: firmware response validation fixes Tristan Madani
2026-11-20 22:59 ` [PATCH v2 wireless 1/2] wifi: nxpwifi: validate ext_scan buf_size against event buffer length Tristan Madani
2026-11-20 22:59 ` [PATCH v2 wireless 2/2] wifi: nxpwifi: 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®