staging: rtl8723bs: fix OOB write in HT_caps_handler()
PATCH 1/1 staging: rtl8723bs: fix OOB write in HT_caps_handler()
Hi Greg,
Here is the fix.
Alexandru
---
The loop in HT_caps_handler() iterates up to pIE->length times, but HT_cap[] is only 26 bytes. pIE->length comes from the HT Capability IE in the association response and can be up to 255. This lets a rogue AP write up to 229 bytes past the array using a bitwise AND into adjacent struct fields.
Clamp the iteration count to the array size.
--- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +2 -1
@@ -935,7 +935,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 < min_t(unsigned int, pIE->length, +sizeof (pmlmeinfo->HT_caps.u.HT_cap)); i++) {if (i !=2 ) {/* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */
Quoted 14 lines · Alexandru Hossu
Hi Greg,
Here is the fix.
Alexandru
---
The loop in
HT_caps_handler()iterates up topIE->lengthtimes, but HT_cap[] is only 26 bytes.pIE->lengthcomes from the HT Capability IE in the association response and can be up to 255. This lets a rogue AP write up to 229 bytes past the array using a bitwise AND into adjacent struct fields.
Quoted 4 lines
Clamp the iteration count to the array size.
Signed-off-by Alexandru Hossu <[email protected]>---
This isn't how you send a patch. Try applying your email with:cat raw_email.txt | git am and use git log to see the problem.
Quoted 8 lines
drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)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 939
Quoted 6 lines
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +2
-1@@ -935,7 +935,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 < min_t(unsigned int, pIE->length, +sizeof (pmlmeinfo->HT_caps.u.HT_cap)); i++) {
Just use min() instead of min_t(). They're both unsigned.
regards,
dan carpenter
Greg KH
maintainerQuoted 26 lines · Alexandru Hossu
Hi Greg,
Here is the fix.
Alexandru
---
The loop in
HT_caps_handler()iterates up topIE->lengthtimes, but HT_cap[] is only 26 bytes.pIE->lengthcomes from the HT Capability IE in the association response and can be up to 255. This lets a rogue AP write up to 229 bytes past the array using a bitwise AND into adjacent struct fields.Clamp the iteration count to the array size.
Signed-off-by Alexandru Hossu <[email protected]>--- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)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 942
Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_wlan_util.c +2
-1@@ -935,7 +935,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 < min_t(unsigned int, pIE->length, +sizeof (pmlmeinfo->HT_caps.u.HT_cap)); i++) {if (i !=2 ) {/* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */
How does this compare with this patch:
https://lore.kernel.org/r/2026041408-grill-mahogany-d1e3@gregkh
or the others sent recently tothe staging list to fix this "issue" that the LLM tools keep tripping over?
thanks,
greg k-h
Quoted 4 lines · Greg KH
How does this compare with this patch:
https://lore.kernel.org/r/2026041408-grill-mahogany-d1e3@gregkhor the others sent recently to the staging list to fix this "issue" that the LLM tools keep tripping over?
Apologies to both of you. I should have checked lore and the current tree state before sending anything. The fix is already in linux-next and I sent this without looking first.
Format note taken, Dan -- will use git send-email properly next time.
Withdrawing this patch.
Alexandru
Was this patch written with LLM? Why is there separate text on the patch? It could have been mentioned in the cover letter.
--
Samet
Quoted 37 lines
2026. 5. 15. 오후 2:08, Alexandru Hossu <[email protected]> 작성:
Hi Greg,
Here is the fix.
Alexandru
---
The loop in
HT_caps_handler()iterates up topIE->lengthtimes, but HT_cap[] is only 26 bytes.pIE->lengthcomes from the HT Capability IE in the association response and can be up to 255. This lets a rogue AP write up to 229 bytes past the array using a bitwise AND into adjacent struct fields.Clamp the iteration count to the array size.
Signed-off-by Alexandru Hossu <[email protected]>---
drivers/staging/rtl8723bs/core/rtw_wlan_util.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/rtl8723bs/core/rtw_wlan_util.c +2
-1@@ -935,7 +935,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 < min_t(unsigned int, pIE->length, +sizeof (pmlmeinfo->HT_caps.u.HT_cap)); i++) {if (i !=2 ) {/* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */
Quoted 2 lines · M.samet Duman
Was this patch written with LLM? Why is there separate text on the patch? It could have been mentioned in the cover letter.
I was experimenting with some local tooling and clearly it didn't produce proper output. Sorry for the noise. Noted for next time.
Alexandru