staging: rtl8723bs: fix OOB write in HT_caps_handler()
Greg Kroah-Hartman
maintainerPATCH 1/1 staging: rtl8723bs: fix OOB write in HT_caps_handler()
HT_caps_handler() loops up to pIE->length, the IE length byte taken directly from an over-the-air association response, and uses the counter to index pmlmeinfo->HT_caps.u.HT_cap[26]. A malicious AP can supply an HT capabilities IE with a length byte up to 255, AND-writing into adjacent fields of struct mlme_ext_info. This is reachable in station mode (the default) via OnAssocRsp.
HT_info_handler() already rejects oversized IEs so do the same thing in HT_caps_handler() to resolve this.
--- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +3 -0
@@ -932,6 +932,9 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)if (phtpriv->ht_option == false)return ; +if (pIE->length >sizeof (pmlmeinfo->HT_caps)) +return ; + pmlmeinfo->HT_caps_enable =1 ;for (i =0 ; i < (pIE->length); i++) {
Signature · 1 line
2.53.0
Quoted 22 lines · Greg Kroah-Hartman
HT_caps_handler()loops up topIE->length, the IE length byte taken directly from an over-the-air association response, and uses the counter to index pmlmeinfo->HT_caps.u.HT_cap[26]. A malicious AP can supply an HT capabilities IE with a length byte up to 255, AND-writing into adjacent fields of structmlme_ext_info. This is reachable in station mode (the default) via OnAssocRsp.
HT_info_handler()already rejects oversized IEs so do the same thing inHT_caps_handler()to resolve this.Fixes 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")Assisted-by gregkh_clanker_t1000Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 +++ 1 file changed, 3 insertions(+)drivers/staging/rtl8723bs/core/rtw_wlan_util.c +0
-0
drivers/staging/rtl8723bs/core/rtw_wlan_util.c void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) · line 940
Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +3
-0@@ -932,6 +932,9 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)if (phtpriv->ht_option == false)return ; +if (pIE->length >sizeof (pmlmeinfo->HT_caps)) +return ; + pmlmeinfo->HT_caps_enable =1 ;for (i =0 ; i < (pIE->length); i++) {
Good catch. Trusting pIE->length blindly from an unauthenticated association response is a classic oob write vector. Since HT_cap is fixed-size within the mlme_ext_info struct, this is a clear remote heap corruption risk if a malicious AP is in range.
Greg Kroah-Hartman
maintainerQuoted 31 lines · Luka Gejak
Quoted 30 lines · Greg Kroah-Hartman
HT_caps_handler()loops up topIE->length, the IE length byte taken directly from an over-the-air association response, and uses the counter to index pmlmeinfo->HT_caps.u.HT_cap[26]. A malicious AP can supply an HT capabilities IE with a length byte up to 255, AND-writing into adjacent fields of structmlme_ext_info. This is reachable in station mode (the default) via OnAssocRsp.
HT_info_handler()already rejects oversized IEs so do the same thing inHT_caps_handler()to resolve this.Fixes 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")Assisted-by gregkh_clanker_t1000Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 +++ 1 file changed, 3 insertions(+)drivers/staging/rtl8723bs/core/rtw_wlan_util.c +3
-0@@ -932,6 +932,9 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)if (phtpriv->ht_option == false)return ; +if (pIE->length >sizeof (pmlmeinfo->HT_caps)) +return ; + pmlmeinfo->HT_caps_enable =1 ;
Quoted 7 lines
drivers/staging/rtl8723bs/core/rtw_wlan_util.c void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) · line 940
Quoted 1 line
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +0
-0for (i =0 ; i < (pIE->length); i++) {Good catch. Trusting
pIE->lengthblindly from an unauthenticated association response is a classic oob write vector. SinceHT_capis fixed-size within themlme_ext_infostruct, this is a clear remote heap corruption risk if a malicious AP is in range.Reviewed-by Luka Gejak <[email protected]>
And it's wrong, as per the AI review :(
Also, you have trailing whitespace on your review comments :)
thanks,
greg k-h