Skip to content

Commit d1ab7f9

Browse files
cyberkunjugregkh
authored andcommitted
staging: rtl8723bs: fix out-of-bounds read in OnBeacon ESR IE parsing
commit 502ddcc upstream. The Extended Supported Rates (ESR) IE handling in OnBeacon accessed *(p + 1 + ielen) and *(p + 2 + ielen) without verifying that these offsets lie within the received frame buffer. A malformed beacon with an ESR IE positioned at the end of the buffer could cause an out-of-bounds read, potentially triggering a kernel panic. Add a boundary check to ensure that the ESR IE body and the subsequent bytes are within the limits of the frame before attempting to access them. This prevents OOB reads caused by malformed beacon frames. Signed-off-by: Navaneeth K <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 61871c8 commit d1ab7f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,11 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
579579

580580
p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, precv_frame->u.hdr.len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_);
581581
if (p && ielen > 0) {
582-
if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D))
583-
/* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */
584-
*(p + 1) = ielen - 1;
582+
if (p + 2 + ielen < pframe + len) {
583+
if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D))
584+
/* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */
585+
*(p + 1) = ielen - 1;
586+
}
585587
}
586588

587589
if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) {

0 commit comments

Comments
 (0)