Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: fix OOB read in rtw_restruct_wmm_ie()
@ 2026-08-05 10:33 イムティヤズ
  2026-08-05 10:54 ` イムティヤズ
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: イムティヤズ @ 2026-08-05 10:33 UTC (permalink / raw)
  To: gregkh
  Cc: linux-staging, イムティヤズ,
	stable

The IE parsing loop in rtw_restruct_wmm_ie() reads in_ie[i + 1] (the
length byte) and, when a vendor specific WMM IE is found, copies 9
bytes starting from in_ie[i], while only guarding the reads with
i + 5 < in_len. When the IE section of a beacon ends with a single
byte remaining, in_ie[i + 1] is read one byte past the end of the
buffer. A crafted IE with a short length field can likewise make the
9-byte copy read past the end of the buffer.

Validate that the 2-byte IE header and the declared payload length
are fully in bounds, and require the WMM IE to be at least 9 bytes
long so that the copy stays within the buffer.

Cc: stable@kernel.org
Signed-off-by: イムティヤズ <reza1234khan1234@gmail.com>
Assisted-by: opencode:auto/best-free
---
 drivers/staging/rtl8723bs/core/rtw_mlme.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c
index 1196ec011455..222eb380500a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -1965,8 +1965,18 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_
 	while (i < in_len) {
 		ielength = initial_out_len;
 
-		if (i + 5 < in_len &&
-		    in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 &&
+		/* break if the 2-byte IE header is not fully in bounds */
+		if (i + 2 > in_len)
+			break;
+
+		/* break if the IE payload declared by the length byte
+		 * extends past the end of the buffer
+		 */
+		if (i + 2 + in_ie[i + 1] > in_len)
+			break;
+
+		if (in_ie[i] == 0xDD && in_ie[i + 1] >= 7 &&
+		    in_ie[i + 2] == 0x00 &&
 		    in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 &&
 		    in_ie[i + 5] == 0x02) {
 			for (j = i; j < i + 9; j++) {
-- 
2.55.0


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

end of thread, other threads:[~2026-08-05 18:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 10:33 [PATCH] staging: rtl8723bs: fix OOB read in rtw_restruct_wmm_ie() イムティヤズ
2026-08-05 10:54 ` イムティヤズ
2026-08-05 11:10 ` イムティヤズ
2026-08-05 11:23 ` Greg KH
2026-08-05 18:47 ` イムティヤズ

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox