All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: fix OOB write in HT_caps_handler()
@ 2026-05-15 10:42 Alexandru Hossu
  2026-05-15 10:51 ` Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alexandru Hossu @ 2026-05-15 10:42 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging

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.

Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 4f41f88908d7..e271d1e395a5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -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. */

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [PATCH] staging: rtl8723bs: fix OOB write in HT_caps_handler()
@ 2026-04-14 17:19 Greg Kroah-Hartman
  2026-04-14 18:39 ` Luka Gejak
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2026-04-14 17:19 UTC (permalink / raw)
  To: linux-staging; +Cc: linux-kernel, Greg Kroah-Hartman

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.

Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
Assisted-by: gregkh_clanker_t1000
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 3242978da36c..a2e016c6a01f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -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++) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-05-15 13:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 10:42 [PATCH] staging: rtl8723bs: fix OOB write in HT_caps_handler() Alexandru Hossu
2026-05-15 10:51 ` Dan Carpenter
2026-05-15 11:35 ` Greg KH
2026-05-15 12:57   ` Alexandru Hossu
2026-05-15 13:01 ` M.samet Duman
2026-05-15 13:12   ` Alexandru Hossu
  -- strict thread matches above, loose matches on Subject: below --
2026-04-14 17:19 Greg Kroah-Hartman
2026-04-14 18:39 ` Luka Gejak
2026-04-26 19:27   ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.