* FAILED: patch "[PATCH] staging: rtl8723bs: fix OOB read / stack overflow in" failed to apply to 5.10-stable tree
@ 2026-09-08 12:41 gregkh
2026-09-10 11:09 ` [PATCH 5.10.y 1/4] staging: rtl8723bs: remove commented out RT_TRACE logs in hal/ and os_dep/ Sasha Levin
0 siblings, 1 reply; 5+ messages in thread
From: gregkh @ 2026-09-08 12:41 UTC (permalink / raw)
To: meatuni001, gregkh; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 99aa998dec83ba180822f70e6d48a514fc81c20d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026090853-convent-spill-68e6@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 99aa998dec83ba180822f70e6d48a514fc81c20d Mon Sep 17 00:00:00 2001
From: Muhammad Bilal <meatuni001@gmail.com>
Date: Tue, 28 Jul 2026 17:54:54 +0500
Subject: [PATCH] staging: rtl8723bs: fix OOB read / stack overflow in
rtw_get_wps_attr()
rtw_get_wps_attr() walks WPS attributes inside a WPS IE taken from
a wireless management frame. For each candidate attribute it only
checks that the fixed 4-byte attribute header (2-byte ID + 2-byte
length) fits inside the IE:
if (attr_ptr + 4 > wps_ie + wps_ielen)
break;
u16 attr_id = get_unaligned_be16(attr_ptr);
u16 attr_data_len = get_unaligned_be16(attr_ptr + 2);
u16 attr_len = attr_data_len + 4;
attr_data_len (and therefore attr_len) is read directly from the
wire and is never checked against the remaining bytes in the IE
before being used as the size of:
memcpy(buf_attr, attr_ptr, attr_len);
Since attr_len is fully attacker controlled (0 to 65535+4), this is
both a heap OOB read of wps_ie, and, more seriously, a stack buffer
overflow at several call sites where buf_attr is a single-byte
stack variable, e.g. rtw_get_wps_attr_content()'s callers passing
WPS_ATTR_SELECTED_REGISTRAR into a stack "u8 sr"/"u8
selected_registrar" (drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c,
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c). A crafted WPS IE in a
beacon or probe response processed during scanning can therefore
smash the stack of the parsing thread.
rtw_get_wps_attr_content() itself has no independent length check
and simply trusts the attr_len it gets back from rtw_get_wps_attr(),
so fixing the bound here also fixes that caller.
The "attr_ptr + 4 > wps_ie + wps_ielen" header check above was added
by commit 1463ca3ec6601 ("staging: rtl8723bs: fix OOB reads in
rtw_get_sec_ie(), rtw_get_wapi_ie(), and rtw_get_wps_attr()"), which
bounded the fixed header but never extended the check to cover the
variable-length attribute data that follows it. Add that missing
check before attr_len is used as a memcpy() length or accepted as a
match.
Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
Link: https://patch.msgid.link/20260728125456.32359-2-meatuni001@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 66f476a46aad..2a58a5cdd9f5 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -741,6 +741,10 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att
u16 attr_data_len = get_unaligned_be16(attr_ptr + 2);
u16 attr_len = attr_data_len + 4;
+ /* Reject attributes whose claimed length runs past the IE */
+ if (attr_ptr + attr_len > wps_ie + wps_ielen)
+ break;
+
if (attr_id == target_attr_id) {
target_attr_ptr = attr_ptr;
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 5.10.y 1/4] staging: rtl8723bs: remove commented out RT_TRACE logs in hal/ and os_dep/ 2026-09-08 12:41 FAILED: patch "[PATCH] staging: rtl8723bs: fix OOB read / stack overflow in" failed to apply to 5.10-stable tree gregkh @ 2026-09-10 11:09 ` Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 2/4] staging: rtl8723bs: remove commented code block Sasha Levin ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Sasha Levin @ 2026-09-10 11:09 UTC (permalink / raw) To: stable; +Cc: Fabio Aiuto, Joe Perches, Greg Kroah-Hartman, Sasha Levin From: Fabio Aiuto <fabioaiuto83@gmail.com> [ Upstream commit 6544c672ee1d250cb55efb750b4cd529e97615f4 ] Remove all commented out TR_TRACE calls. Remove all of the RT_TRACE logs in hal/ and os_dep/ file as they currently do nothing as they require the code to be modified by hand in order to be turned on. This obviously has not happened since the code was merged. Moreover it relies on an unneeded private log level tracing which overrides the in-kernel public one, so just remove them as they are unused. Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com> Link: https://lore.kernel.org/r/85338f2b2cffb530efbd987064d146fc2be49c72.1617640221.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: 99aa998dec83 ("staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 3 --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 8 -------- drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c | 2 -- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 ------ 5 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index 85ea535dd6e93..167657f33cebe 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -1852,7 +1852,6 @@ void PHY_IQCalibrate_8723B( bResult = FAIL; break; } - /* RT_TRACE(_module_mp_, _drv_notice_, ("Switch to S1 TxIQC(offset, data) = (0x%X, 0x%X)\n", offset, data)); */ PHY_SetBBReg(pDM_Odm->Adapter, offset, bMaskDWord, data); } @@ -1869,7 +1868,6 @@ void PHY_IQCalibrate_8723B( bResult = FAIL; break; } - /* RT_TRACE(_module_mp_, _drv_notice_, ("Switch to S1 RxIQC (offset, data) = (0x%X, 0x%X)\n", offset, data)); */ PHY_SetBBReg(pDM_Odm->Adapter, offset, bMaskDWord, data); } @@ -1955,7 +1953,6 @@ void PHY_IQCalibrate_8723B( } } } -/* RT_TRACE(COMP_INIT, DBG_LOUD, ("Release Mutex in IQCalibrate\n")); */ for (i = 0; i < 4; i++) { RegE94 = result[i][0]; diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index f806b3c7ee6ae..a50cda70b6a79 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1789,7 +1789,6 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, /* if (band_type == BAND_ON_5G && pwr_lmt == MAX_POWER_INDEX) { if (idx_bandwidth == 0 || idx_bandwidth == 1) { - RT_TRACE(COMP_INIT, DBG_LOUD, ("No power limit table of the specified band %d, bandwidth %d, ratesection %d, rf path %d\n", idx_band, idx_bandwidth, idx_rate_sctn, rf_path)); if (idx_rate_sctn == 2) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 44dca46a799ac..0933cc0906dbf 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2709,7 +2709,6 @@ void Hal_EfuseParseEEPROMVer_8723B( { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */ if (!AutoLoadFail) pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_8723B]; else @@ -2792,7 +2791,6 @@ void Hal_EfuseParseCustomerID_8723B( { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */ if (!AutoLoadFail) pHalData->EEPROMCustomerID = hwinfo[EEPROM_CustomID_8723B]; else @@ -2815,7 +2813,6 @@ void Hal_EfuseParseXtal_8723B( { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */ if (!AutoLoadFail) { pHalData->CrystalCap = hwinfo[EEPROM_XTAL_8723B]; if (pHalData->CrystalCap == 0xFF) @@ -2833,7 +2830,6 @@ void Hal_EfuseParseThermalMeter_8723B( { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */ /* */ /* ThermalMeter from EEPROM */ /* */ @@ -3144,8 +3140,6 @@ static void rtl8723b_fill_default_txdesc( ptxdesc->usb_txagg_num = pxmitframe->agg_num; } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) { -/* RT_TRACE(_module_hal_xmit_c_, _drv_notice_, ("%s: MGNT_FRAMETAG\n", __func__)); */ - ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */ ptxdesc->qsel = pattrib->qsel; ptxdesc->rate_id = pattrib->raid; /* Rate ID */ @@ -3961,9 +3955,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) ulCommand = ulCommand | CAM_POLLINIG | CAM_WRITE; /* write content 0 is equall to mark invalid */ rtw_write32(padapter, WCAMI, ulContent); /* mdelay(40); */ - /* RT_TRACE(COMP_SEC, DBG_LOUD, ("CAM_empty_entry(): WRITE A4: %lx\n", ulContent)); */ rtw_write32(padapter, RWCAM, ulCommand); /* mdelay(40); */ - /* RT_TRACE(COMP_SEC, DBG_LOUD, ("CAM_empty_entry(): WRITE A0: %lx\n", ulCommand)); */ } } break; diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c index aafceaf9b1394..b3ec240ff215f 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c @@ -74,7 +74,6 @@ void PHY_RF6052SetBandwidth8723B( break; default: - /* RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n", Bandwidth)); */ break; } @@ -153,7 +152,6 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv); - /* RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); */ return _SUCCESS; } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 8107ee03b9642..d9b53fff66a6b 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -4313,7 +4313,6 @@ static int rtw_wx_set_priv(struct net_device *dev, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *dwrq = (struct iw_point *)awrq; - /* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, ("+rtw_wx_set_priv\n")); */ if (dwrq->length == 0) return -EFAULT; @@ -4326,11 +4325,6 @@ static int rtw_wx_set_priv(struct net_device *dev, return -EFAULT; } - - /* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, */ - /* ("rtw_wx_set_priv: %s req =%s\n", */ - /* dev->name, ext)); */ - #ifdef DEBUG_RTW_WX_SET_PRIV if (!(ext_dbg = vmalloc(len))) { vfree(ext, len); -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 2/4] staging: rtl8723bs: remove commented code block 2026-09-10 11:09 ` [PATCH 5.10.y 1/4] staging: rtl8723bs: remove commented out RT_TRACE logs in hal/ and os_dep/ Sasha Levin @ 2026-09-10 11:09 ` Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 3/4] staging: rtl8723bs: remove commented out DBG_871X logs Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 4/4] staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr() Sasha Levin 2 siblings, 0 replies; 5+ messages in thread From: Sasha Levin @ 2026-09-10 11:09 UTC (permalink / raw) To: stable; +Cc: Fabio Aiuto, Joe Perches, Greg Kroah-Hartman, Sasha Levin From: Fabio Aiuto <fabioaiuto83@gmail.com> [ Upstream commit bcc84e52bcc5a9e76102b76b9d442a290a408574 ] remove commented 5G code block in hal/hal_com_phycfg.c which contained removed RT_TRACE log as reported in the driver's TODO file: - find and remove remaining code valid only for 5 GHz. Most of the obvious ones have been removed, but things like channel > 14 still exist. so just removed obsolete commented code. Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com> Link: https://lore.kernel.org/r/b930cfc476c97f2ae5c5b90c1314a6270d56a539.1617640221.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: 99aa998dec83 ("staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- .../staging/rtl8723bs/hal/hal_com_phycfg.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index a50cda70b6a79..f29f46d126525 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -1784,25 +1784,6 @@ s8 phy_get_tx_pwr_lmt(struct adapter *adapter, u32 reg_pwr_tbl_sel, DBG_871X("No power limit table of the specified band\n"); } - /* combine 5G VHT & HT rate */ - /* 5G 20M and 40M HT and VHT can cross reference */ - /* - if (band_type == BAND_ON_5G && pwr_lmt == MAX_POWER_INDEX) { - if (idx_bandwidth == 0 || idx_bandwidth == 1) { - idx_band, idx_bandwidth, - idx_rate_sctn, rf_path)); - if (idx_rate_sctn == 2) - pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][4][idx_channel][rf_path]; - else if (idx_rate_sctn == 4) - pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][2][idx_channel][rf_path]; - else if (idx_rate_sctn == 3) - pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][5][idx_channel][rf_path]; - else if (idx_rate_sctn == 5) - pwr_lmt = hal_data->TxPwrLimit_5G[idx_regulation][idx_bandwidth][3][idx_channel][rf_path]; - } - } - */ - /* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */ /* idx_regulation, hal_data->CurrentBandType, bandwidth, rf_path, data_rate, channel, pwr_lmt); */ return pwr_lmt; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 3/4] staging: rtl8723bs: remove commented out DBG_871X logs 2026-09-10 11:09 ` [PATCH 5.10.y 1/4] staging: rtl8723bs: remove commented out RT_TRACE logs in hal/ and os_dep/ Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 2/4] staging: rtl8723bs: remove commented code block Sasha Levin @ 2026-09-10 11:09 ` Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 4/4] staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr() Sasha Levin 2 siblings, 0 replies; 5+ messages in thread From: Sasha Levin @ 2026-09-10 11:09 UTC (permalink / raw) To: stable; +Cc: Fabio Aiuto, Greg Kroah-Hartman, Sasha Levin From: Fabio Aiuto <fabioaiuto83@gmail.com> [ Upstream commit 68e79909e1d84251ae1889cbad45672f5ba85d7e ] remove all commented out DBG_871X logs unmatched by semantic patch. Signed-off-by: Fabio Aiuto <fabioaiuto83@gmail.com> Link: https://lore.kernel.org/r/125e216e3bb5bc938e06b15dadfbbf51d9517dde.1617802415.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> For this stable backport, retain only the commented DBG_871X deletion in rtw_get_wps_attr(). It removes the line that prevents the unchanged patch for 99aa998dec83 ("staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr()") from matching its insertion context. Drop the unrelated log cleanup in the other 25 files. Those hunks are unnecessary for the target and overlap older stable code, including existing bounds checks and debug counters. No executable code or functions are added or changed by this dependency. [ sashal: Reduced backport -- upstream 68e79909e1d84 touches 26 file(s), this backport carries 1. Not backported here: drivers/staging/rtl8723bs/core/rtw_ap.c drivers/staging/rtl8723bs/core/rtw_cmd.c drivers/staging/rtl8723bs/core/rtw_efuse.c drivers/staging/rtl8723bs/core/rtw_io.c drivers/staging/rtl8723bs/core/rtw_ioctl_set.c drivers/staging/rtl8723bs/core/rtw_mlme.c drivers/staging/rtl8723bs/core/rtw_mlme_ext.c drivers/staging/rtl8723bs/core/rtw_pwrctrl.c ... and 17 more This note is generated from the file lists only; see the resolution record for the reasoning. ] Stable-dep-of: 99aa998dec83 ("staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr()") Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 3f2ee8b34e254..82bd36f3c1cfe 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -798,7 +798,6 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att u16 attr_data_len = get_unaligned_be16(attr_ptr + 2); u16 attr_len = attr_data_len + 4; - /* DBG_871X("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */ if (attr_id == target_attr_id) { target_attr_ptr = attr_ptr; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5.10.y 4/4] staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr() 2026-09-10 11:09 ` [PATCH 5.10.y 1/4] staging: rtl8723bs: remove commented out RT_TRACE logs in hal/ and os_dep/ Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 2/4] staging: rtl8723bs: remove commented code block Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 3/4] staging: rtl8723bs: remove commented out DBG_871X logs Sasha Levin @ 2026-09-10 11:09 ` Sasha Levin 2 siblings, 0 replies; 5+ messages in thread From: Sasha Levin @ 2026-09-10 11:09 UTC (permalink / raw) To: stable; +Cc: Muhammad Bilal, Greg Kroah-Hartman, Sasha Levin From: Muhammad Bilal <meatuni001@gmail.com> [ Upstream commit 99aa998dec83ba180822f70e6d48a514fc81c20d ] rtw_get_wps_attr() walks WPS attributes inside a WPS IE taken from a wireless management frame. For each candidate attribute it only checks that the fixed 4-byte attribute header (2-byte ID + 2-byte length) fits inside the IE: if (attr_ptr + 4 > wps_ie + wps_ielen) break; u16 attr_id = get_unaligned_be16(attr_ptr); u16 attr_data_len = get_unaligned_be16(attr_ptr + 2); u16 attr_len = attr_data_len + 4; attr_data_len (and therefore attr_len) is read directly from the wire and is never checked against the remaining bytes in the IE before being used as the size of: memcpy(buf_attr, attr_ptr, attr_len); Since attr_len is fully attacker controlled (0 to 65535+4), this is both a heap OOB read of wps_ie, and, more seriously, a stack buffer overflow at several call sites where buf_attr is a single-byte stack variable, e.g. rtw_get_wps_attr_content()'s callers passing WPS_ATTR_SELECTED_REGISTRAR into a stack "u8 sr"/"u8 selected_registrar" (drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c, drivers/staging/rtl8723bs/core/rtw_mlme_ext.c). A crafted WPS IE in a beacon or probe response processed during scanning can therefore smash the stack of the parsing thread. rtw_get_wps_attr_content() itself has no independent length check and simply trusts the attr_len it gets back from rtw_get_wps_attr(), so fixing the bound here also fixes that caller. The "attr_ptr + 4 > wps_ie + wps_ielen" header check above was added by commit 1463ca3ec6601 ("staging: rtl8723bs: fix OOB reads in rtw_get_sec_ie(), rtw_get_wapi_ie(), and rtw_get_wps_attr()"), which bounded the fixed header but never extended the check to cover the variable-length attribute data that follows it. Add that missing check before attr_len is used as a memcpy() length or accepted as a match. Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable@vger.kernel.org Signed-off-by: Muhammad Bilal <meatuni001@gmail.com> Link: https://patch.msgid.link/20260728125456.32359-2-meatuni001@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 82bd36f3c1cfe..196349bab11ea 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -798,6 +798,10 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att u16 attr_data_len = get_unaligned_be16(attr_ptr + 2); u16 attr_len = attr_data_len + 4; + /* Reject attributes whose claimed length runs past the IE */ + if (attr_ptr + attr_len > wps_ie + wps_ielen) + break; + if (attr_id == target_attr_id) { target_attr_ptr = attr_ptr; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-10 11:09 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-08 12:41 FAILED: patch "[PATCH] staging: rtl8723bs: fix OOB read / stack overflow in" failed to apply to 5.10-stable tree gregkh 2026-09-10 11:09 ` [PATCH 5.10.y 1/4] staging: rtl8723bs: remove commented out RT_TRACE logs in hal/ and os_dep/ Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 2/4] staging: rtl8723bs: remove commented code block Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 3/4] staging: rtl8723bs: remove commented out DBG_871X logs Sasha Levin 2026-09-10 11:09 ` [PATCH 5.10.y 4/4] staging: rtl8723bs: fix OOB read / stack overflow in rtw_get_wps_attr() Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox