[PATCH wireless 2/3] wifi: mwifiex: check TLV header size in ext scan report
From: Elkin Cruz
Date: Wed Nov 25 2026 - 16:02:02 EST
mwifiex_handle_event_ext_scan_report() loops while bytes_left is
non-zero and immediately dereferences tlv->header.type and
tlv->header.len (4 bytes) before checking whether bytes_left can hold a
complete struct mwifiex_ie_types_header. When 1 <= bytes_left < 4, this
reads past the end of the firmware event buffer.
Require bytes_left >= sizeof(struct mwifiex_ie_types_header) in the
outer loop condition, matching the inner TLV loop directly below.
Fixes: 21f58d200388 ("mwifiex: implement extended scan feature")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Elkin Cruz <elkin@xxxxxxxxxx>
---
drivers/net/wireless/marvell/mwifiex/scan.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index bdd4b8465863..53aa16c1df33 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -2649,7 +2649,8 @@ int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
tlv = (struct mwifiex_ie_types_data *)scan_resp;
- for (idx = 0; idx < num_of_set && bytes_left; idx++) {
+ for (idx = 0; idx < num_of_set &&
+ bytes_left >= sizeof(struct mwifiex_ie_types_header); idx++) {
type = le16_to_cpu(tlv->header.type);
len = le16_to_cpu(tlv->header.len);
if (bytes_left < sizeof(struct mwifiex_ie_types_header) + len) {
--
2.56.1.839.g22a8290db9-goog