* [PATCH wireless 0/3] wifi: nxpwifi: validate firmware response sizes
@ 2026-11-02 12:48 Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 1/3] wifi: nxpwifi: validate HE capability TLV length in firmware response Tristan Madani
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tristan Madani @ 2026-11-02 12:48 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, Johannes Berg, linux-wireless, linux-kernel,
Tristan Madani
From: Tristan Madani <tristan@talencesecurity.com>
nxpwifi inherits several patterns from mwifiex where firmware-provided
lengths and counts are used to bound loops and copies without
validation against the actual response buffer size. A malformed
firmware response can cause reads past the buffer.
This series adds bounds checks to three such paths:
1/3 - HE capability TLV length in 11ax config response
2/3 - ext_scan buf_size against event buffer length
3/3 - command response size against response skb length
All three were introduced with the driver in 73b01e57ed3e ("wifi: nxp:
add nxpwifi driver for IW61x").
Tristan Madani (3):
wifi: nxpwifi: validate HE capability TLV length in firmware response
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/11ax.c | 3 +++
drivers/net/wireless/nxp/nxpwifi/scan.c | 9 +++++++++
drivers/net/wireless/nxp/nxpwifi/cmdevt.c | 14 ++++++++++++++
3 files changed, 26 insertions(+)
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH wireless 1/3] wifi: nxpwifi: validate HE capability TLV length in firmware response
2026-11-02 12:48 [PATCH wireless 0/3] wifi: nxpwifi: validate firmware response sizes Tristan Madani
@ 2026-11-02 12:48 ` Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 2/3] wifi: nxpwifi: validate ext_scan buf_size against event buffer length Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 3/3] wifi: nxpwifi: validate command response size against " Tristan Madani
2 siblings, 0 replies; 4+ messages in thread
From: Tristan Madani @ 2026-11-02 12:48 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, Johannes Berg, linux-wireless, linux-kernel,
Tristan Madani, stable
From: Tristan Madani <tristan@talencesecurity.com>
nxpwifi_ret_11ax_cfg() parses TLV data from firmware without checking
that each TLV's declared length fits within the remaining buffer. A
firmware response with an oversized TLV length causes reads past the
response buffer.
Add a bounds check that the TLV header plus its declared length does
not exceed the remaining data before processing the TLV contents.
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/11ax.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/nxp/nxpwifi/11ax.c b/drivers/net/wireless/nxp/nxpwifi/11ax.c
index dc1e747383eca..1006b4a84de73 100644
--- a/drivers/net/wireless/nxp/nxpwifi/11ax.c
+++ b/drivers/net/wireless/nxp/nxpwifi/11ax.c
@@ -215,6 +215,9 @@ int nxpwifi_ret_11ax_cfg(struct nxpwifi_private *priv,
tlv_type = le16_to_cpu(header->type);
tlv_len = le16_to_cpu(header->len);
+ if (sizeof(*header) + tlv_len > left_len)
+ break;
+
if (tlv_type == TLV_TYPE_EXTENSION_ID) {
ext_id = *((u8 *)header + sizeof(*header) + 1);
if (ext_id == WLAN_EID_EXT_HE_CAPABILITY) {
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH wireless 2/3] wifi: nxpwifi: validate ext_scan buf_size against event buffer length
2026-11-02 12:48 [PATCH wireless 0/3] wifi: nxpwifi: validate firmware response sizes Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 1/3] wifi: nxpwifi: validate HE capability TLV length in firmware response Tristan Madani
@ 2026-11-02 12:48 ` Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 3/3] wifi: nxpwifi: validate command response size against " Tristan Madani
2 siblings, 0 replies; 4+ messages in thread
From: Tristan Madani @ 2026-11-02 12:48 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, Johannes Berg, linux-wireless, linux-kernel,
Tristan Madani, stable
From: Tristan Madani <tristan@talencesecurity.com>
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 f3becafb9c23c..e7d98463ad18b 100644
--- a/drivers/net/wireless/nxp/nxpwifi/scan.c
+++ b/drivers/net/wireless/nxp/nxpwifi/scan.c
@@ -2427,6 +2427,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] 4+ messages in thread
* [PATCH wireless 3/3] wifi: nxpwifi: validate command response size against buffer length
2026-11-02 12:48 [PATCH wireless 0/3] wifi: nxpwifi: validate firmware response sizes Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 1/3] wifi: nxpwifi: validate HE capability TLV length in firmware response Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 2/3] wifi: nxpwifi: validate ext_scan buf_size against event buffer length Tristan Madani
@ 2026-11-02 12:48 ` Tristan Madani
2 siblings, 0 replies; 4+ messages in thread
From: Tristan Madani @ 2026-11-02 12:48 UTC (permalink / raw)
To: Jeff Chen
Cc: Francesco Dolcini, Johannes Berg, linux-wireless, linux-kernel,
Tristan Madani, stable
From: Tristan Madani <tristan@talencesecurity.com>
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>
---
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..50aabf1a72b2e 100644
--- a/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
+++ b/drivers/net/wireless/nxp/nxpwifi/cmdevt.c
@@ -722,6 +722,20 @@ int nxpwifi_process_cmdresp(struct nxpwifi_adapter *adapter)
orig_cmdresp_no = le16_to_cpu(resp->command);
cmdresp_no = (orig_cmdresp_no & HOST_CMD_ID_MASK);
+ 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_no != cmdresp_no) {
nxpwifi_dbg(adapter, ERROR,
"cmdresp error: cmd=0x%x cmd_resp=0x%x\n",
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-02 12:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 12:48 [PATCH wireless 0/3] wifi: nxpwifi: validate firmware response sizes Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 1/3] wifi: nxpwifi: validate HE capability TLV length in firmware response Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 2/3] wifi: nxpwifi: validate ext_scan buf_size against event buffer length Tristan Madani
2026-11-02 12:48 ` [PATCH wireless 3/3] 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®