Skip to content

Commit 3bf39f7

Browse files
ahossugregkh
authored andcommitted
staging: rtl8723bs: fix OOB reads in is_ap_in_tkip() IE loop
The loop in is_ap_in_tkip() iterates over IEs without verifying that enough bytes remain before dereferencing the IE header or its payload: - pIE->element_id and pIE->length are read without checking that i + sizeof(*pIE) <= ie_length, so a truncated IE at the end of the buffer causes an OOB read. - For WLAN_EID_VENDOR_SPECIFIC the code compares pIE->data + 12, which requires pIE->length >= 16. For WLAN_EID_RSN it compares pIE->data + 8, requiring pIE->length >= 12. Neither requirement is checked. Add the missing IE header and payload bounds checks and guard each data access with an explicit pIE->length minimum, matching the pattern established in update_beacon_info(). Fixes: 554c0a3 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable <stable@kernel.org> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com> Link: https://patch.msgid.link/20260522004531.1038924-7-hossu.alexandru@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f965420 commit 3bf39f7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/staging/rtl8723bs/core/rtw_wlan_util.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,23 +1308,31 @@ unsigned int is_ap_in_tkip(struct adapter *padapter)
13081308
for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.ie_length;) {
13091309
pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.ies + i);
13101310

1311+
if (i + sizeof(*pIE) > pmlmeinfo->network.ie_length)
1312+
break;
1313+
if (i + sizeof(*pIE) + pIE->length > pmlmeinfo->network.ie_length)
1314+
break;
1315+
13111316
switch (pIE->element_id) {
13121317
case WLAN_EID_VENDOR_SPECIFIC:
1313-
if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4)))
1318+
if (pIE->length >= 16 &&
1319+
!memcmp(pIE->data, RTW_WPA_OUI, 4) &&
1320+
!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))
13141321
return true;
13151322

13161323
break;
13171324

13181325
case WLAN_EID_RSN:
1319-
if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4))
1326+
if (pIE->length >= 12 &&
1327+
!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4))
13201328
return true;
13211329
break;
13221330

13231331
default:
13241332
break;
13251333
}
13261334

1327-
i += (pIE->length + 2);
1335+
i += sizeof(*pIE) + pIE->length;
13281336
}
13291337

13301338
return false;

0 commit comments

Comments
 (0)