]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: rtl8723bs: fix OOB reads in rtw_get_wps_ie()
authorMoksh Panicker <mokshpanicker.7@gmail.com>
Thu, 25 Jun 2026 20:29:11 +0000 (20:29 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jul 2026 12:23:13 +0000 (14:23 +0200)
rtw_get_wps_ie() iterates over IE data from network frames without
validating that the IE header and payload fit within the remaining
buffer before reading them. Specifically:

- in_ie[cnt + 1] is read without checking cnt + 1 < in_len
- memcmp(&in_ie[cnt + 2], ...) accesses cnt + 2 without bounds check
- in_ie[cnt + 1] is used as length without verifying payload fits

Add bounds checks at the top of the loop body to break early if fewer
than 2 bytes remain for the IE header, or if the declared payload
extends past the end of the buffer. Also require at least 4 bytes of
payload before comparing the WPS OUI.

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
Link: https://patch.msgid.link/20260625202911.26782-1-mokshpanicker.7@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/core/rtw_ieee80211.c

index 54f805a6b5ce559476d7ef2b221e40a0cd0d9d4e..863ddf84621860bca6ab05eaa554a6576cb07ee8 100644 (file)
@@ -670,7 +670,14 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
        while (cnt < in_len) {
                eid = in_ie[cnt];
 
-               if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) {
+               if (cnt + 2 > in_len)
+                       break;
+
+               if (in_ie[cnt + 1] + 2 > in_len - cnt)
+                       break;
+
+               if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (in_ie[cnt + 1] >= 4) &&
+                   (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) {
                        wpsie_ptr = &in_ie[cnt];
 
                        if (wps_ie)