]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: rtl8723bs: fix OOB write in HT_caps_handler()
authorAlexandru Hossu <hossu.alexandru@gmail.com>
Fri, 22 May 2026 00:45:28 +0000 (02:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Jul 2026 11:43:19 +0000 (13:43 +0200)
HT_caps_handler() iterates pIE->length bytes and writes into
HT_caps.u.HT_cap[], which is a fixed 26-byte array (sizeof struct
HT_caps_element). Because pIE->length is a raw u8 from an over-the-air
802.11 AssocResponse frame and is never validated, a malicious AP can
set it up to 255, causing up to 229 bytes of out-of-bounds writes into
adjacent fields of struct mlme_ext_info.

Truncate the iteration count to the size of HT_caps.u.HT_cap using
umin() so that data from a longer-than-expected IE is silently ignored
rather than written out of bounds, preserving interoperability with APs
that pad the element. An early return on oversized IEs was considered
but rejected: it would bypass the pmlmeinfo->HT_caps_enable = 1
assignment that precedes the loop, silently disabling HT mode for APs
that append extra bytes to the HT Capabilities IE.

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable <stable@kernel.org>
Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Link: https://patch.msgid.link/20260522004531.1038924-5-hossu.alexandru@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/core/rtw_wlan_util.c

index b355d8a3ceabcb9c9ce0a187a335cc71969c164d..4c0eb93f412e4fdd823fa2eee82fbc2ba709ae7e 100644 (file)
@@ -909,7 +909,8 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
 
        pmlmeinfo->HT_caps_enable = 1;
 
-       for (i = 0; i < (pIE->length); i++) {
+       for (i = 0; i < umin(pIE->length,
+                            sizeof(pmlmeinfo->HT_caps.u.HT_cap)); i++) {
                if (i != 2) {
                        /* Commented by Albert 2010/07/12 */
                        /* Got the endian issue here. */