Skip to content

Commit 6ef0e1c

Browse files
cyberkunjugregkh
authored andcommitted
staging: rtl8723bs: fix stack buffer overflow in OnAssocReq IE parsing
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>
1 parent 154828b commit 6ef0e1c

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
@@ -1028,14 +1028,17 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
10281028
status = WLAN_STATUS_CHALLENGE_FAIL;
10291029
goto OnAssocReqFail;
10301030
} else {
1031+
if (ie_len > sizeof(supportRate))
1032+
ie_len = sizeof(supportRate);
1033+
10311034
memcpy(supportRate, p+2, ie_len);
10321035
supportRateNum = ie_len;
10331036

10341037
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len,
10351038
pkt_len - WLAN_HDR_A3_LEN - ie_offset);
10361039
if (p) {
10371040

1038-
if (supportRateNum <= sizeof(supportRate)) {
1041+
if (supportRateNum + ie_len <= sizeof(supportRate)) {
10391042
memcpy(supportRate+supportRateNum, p+2, ie_len);
10401043
supportRateNum += ie_len;
10411044
}

0 commit comments

Comments
 (0)