Skip to content

Commit e841d8e

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 <knavaneeth786@gmail.com> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c0d93d6 commit e841d8e

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
@@ -1042,14 +1042,17 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
10421042
status = WLAN_STATUS_CHALLENGE_FAIL;
10431043
goto OnAssocReqFail;
10441044
} else {
1045+
if (ie_len > sizeof(supportRate))
1046+
ie_len = sizeof(supportRate);
1047+
10451048
memcpy(supportRate, p+2, ie_len);
10461049
supportRateNum = ie_len;
10471050

10481051
p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len,
10491052
pkt_len - WLAN_HDR_A3_LEN - ie_offset);
10501053
if (p) {
10511054

1052-
if (supportRateNum <= sizeof(supportRate)) {
1055+
if (supportRateNum + ie_len <= sizeof(supportRate)) {
10531056
memcpy(supportRate+supportRateNum, p+2, ie_len);
10541057
supportRateNum += ie_len;
10551058
}

0 commit comments

Comments
 (0)