Skip to content

Commit 61871c8

Browse files
cyberkunjugregkh
authored andcommitted
staging: rtl8723bs: fix stack buffer overflow in OnAssocReq IE parsing
commit 6ef0e1c 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 <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a54e2b2 commit 61871c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,14 +1033,17 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
10331033
status = WLAN_STATUS_CHALLENGE_FAIL;
10341034
goto OnAssocReqFail;
10351035
} else {
1036+
if (ie_len > sizeof(supportRate))
1037+
ie_len = sizeof(supportRate);
1038+
10361039
memcpy(supportRate, p+2, ie_len);
10371040
supportRateNum = ie_len;
10381041

10391042
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len,
10401043
pkt_len - WLAN_HDR_A3_LEN - ie_offset);
10411044
if (p) {
10421045

1043-
if (supportRateNum <= sizeof(supportRate)) {
1046+
if (supportRateNum + ie_len <= sizeof(supportRate)) {
10441047
memcpy(supportRate+supportRateNum, p+2, ie_len);
10451048
supportRateNum += ie_len;
10461049
}

0 commit comments

Comments
 (0)