Skip to content

Commit 5354a56

Browse files
cyberkunjuUlrich Hecht
authored andcommitted
staging: rtl8723bs: fix stack buffer overflow in OnAssocReq IE parsing
commit 6ef0e1c10455927867cac8f0ed6b49f328f8cf95 upstream. The Supported Rates IE length from an incoming Association Request frame was used directly as the memcpy() length when copying into a fixed-size 16-byte stack buffer (supportRate). A malicious station can advertise an IE length larger than 16 bytes, causing a stack buffer overflow. Clamp ie_len to the buffer size before copying the Supported Rates IE, and correct the bounds check when merging Extended Supported Rates to prevent a second potential overflow. This prevents kernel stack corruption triggered by malformed association requests. Signed-off-by: Navaneeth K <knavaneeth786@gmail.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent f48dfa7 commit 5354a56

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,14 +1296,17 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
12961296
status = _STATS_FAILURE_;
12971297
goto OnAssocReqFail;
12981298
} else {
1299+
if (ie_len > sizeof(supportRate))
1300+
ie_len = sizeof(supportRate);
1301+
12991302
memcpy(supportRate, p+2, ie_len);
13001303
supportRateNum = ie_len;
13011304

13021305
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len,
13031306
pkt_len - WLAN_HDR_A3_LEN - ie_offset);
13041307
if (p != NULL) {
13051308

1306-
if (supportRateNum <= sizeof(supportRate)) {
1309+
if (supportRateNum + ie_len <= sizeof(supportRate)) {
13071310
memcpy(supportRate+supportRateNum, p+2, ie_len);
13081311
supportRateNum += ie_len;
13091312
}

0 commit comments

Comments
 (0)