From: Tristan Madani <tristmd@gmail.com>
To: Brian Norris <briannorris@chromium.org>
Cc: Jeff Chen <jeff.chen_1@nxp.com>,
Francesco Dolcini <francesco@dolcini.it>,
Bing Zhao <bzhao@marvell.com>,
Amitkumar Karwar <akarwar@marvell.com>,
"John W . Linville" <linville@tuxdriver.com>,
linux-wireless@vger.kernel.org, stable@vger.kernel.org,
Tristan Madani <tristan@talencesecurity.com>
Subject: [PATCH v2 wireless 1/2] wifi: mwifiex: validate ext_scan buf_size against event buffer length
Date: Tue, 24 Nov 2026 17:36:16 +0000 [thread overview]
Message-ID: <20261124173617.802875-2-tristmd@gmail.com> (raw)
In-Reply-To: <20261124173617.802875-1-tristmd@gmail.com>
From: Tristan Madani <tristan@talencesecurity.com>
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
next prev parent reply other threads:[~2026-11-24 17:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:36 [PATCH v2 wireless 0/2] wifi: mwifiex: validate firmware response sizes Tristan Madani
2026-11-24 17:36 ` Tristan Madani [this message]
2026-11-24 17:36 ` [PATCH v2 wireless 2/2] wifi: mwifiex: validate command response size against buffer length Tristan Madani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124173617.802875-2-tristmd@gmail.com \
--to=tristmd@gmail.com \
--cc=akarwar@marvell.com \
--cc=briannorris@chromium.org \
--cc=bzhao@marvell.com \
--cc=francesco@dolcini.it \
--cc=jeff.chen_1@nxp.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=stable@vger.kernel.org \
--cc=tristan@talencesecurity.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox