* [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities
@ 2026-04-17 6:10 Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 6:10 UTC (permalink / raw)
To: gregkh
Cc: error27, luka.gejak, hansg, linux-staging, linux-kernel, stable,
Delene Tchio Romuald
This series fixes five remotely-triggerable memory safety issues in
the rtl8723bs driver. All of them are reachable from the air by an
attacker within WiFi radio range, without authentication, via
crafted management or data frames:
1. Heap buffer overflow in recvframe_defrag() when reassembling
fragmented frames whose total payload exceeds the receive
buffer capacity.
2. Integer underflow in TKIP MIC verification when a frame is
shorter than the sum of header, IV, ICV and MIC sizes.
3. Out-of-bounds read in portctrl() when a non-EAPOL frame is
shorter than the 802.11 header + IV + LLC + ether_type.
4. Out-of-bounds reads in three IE walkers (rtw_get_wapi_ie(),
rtw_get_sec_ie(), rtw_get_wps_ie()) due to missing validation
of the TLV length byte and of the byte ranges touched by the
subsequent memcmp() calls.
5. Integer underflow in rtw_wep_decrypt() when a WEP frame is
shorter than the header + IV + ICV.
Each patch was found by code review and is not tested on hardware.
Changes since v5:
- Patch 1/5: restore the "/* memcpy */" comment that v5 had
removed as drive-by cleanup (Dan Carpenter).
- Patch 3/5: drop the unrelated cleanups (ptr = ptr + X -> ptr +=
X, inversion of the ether_type == eapol_type branch into
direct return NULL); the patch now only adds the short-frame
length check before dereferencing the LLC header (Dan
Carpenter).
- Patches 2/5, 4/5 and 5/5 are unchanged.
Changes since v4:
- Patch 1/5: collapse the identical cleanup sites in
recvframe_defrag() into a single out_err label (Dan Carpenter).
- Patch 4/5: in addition to the outer TLV length check, add an
inner bound check before each memcmp() so that the OUI read at
offset 6 (WAPI) or offset 2 (WPA/WPS) stays inside the declared
element (Dan Carpenter).
- Patch 5/5: tighten the length check to also cover the 4-byte
ICV, so that the subsequent crc32_le(payload, length - 4) call
cannot underflow length - 4.
Changes since v3:
- All patches: add Fixes: tag pointing at the driver import and
add Cc: stable per Dan Carpenter.
Changes since v2:
- Sent as numbered series with cover letter.
Changes since v1:
- Rebased on staging-next.
Delene Tchio Romuald (5):
staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag()
staging: rtl8723bs: fix integer underflow in TKIP MIC verification
staging: rtl8723bs: fix out-of-bounds read in portctrl()
staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions
staging: rtl8723bs: fix negative length in WEP decryption
.../staging/rtl8723bs/core/rtw_ieee80211.c | 70 +++++++++++++------
drivers/staging/rtl8723bs/core/rtw_recv.c | 51 +++++++++-----
drivers/staging/rtl8723bs/core/rtw_security.c | 6 ++
3 files changed, 87 insertions(+), 40 deletions(-)
base-commit: bf9c95f3eeefb7fc4b4a6380cc23f1dca744e379
--
2.43.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag()
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
@ 2026-04-17 6:10 ` Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification Delene Tchio Romuald
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 6:10 UTC (permalink / raw)
To: gregkh
Cc: error27, luka.gejak, hansg, linux-staging, linux-kernel, stable,
Delene Tchio Romuald
In recvframe_defrag(), a memcpy() copies fragment data into the
reassembly buffer before validating that the buffer has sufficient
space. If the total reassembled payload exceeds the receive buffer
capacity, this results in a heap buffer overflow.
Additionally, the return values of recvframe_pull() and
recvframe_pull_tail() were ignored. On failure those helpers revert
their pointer updates and return NULL; continuing past such a
failure would leave pfhdr->rx_tail at its pre-strip value, so the
subsequent bounds check against rx_end - rx_tail would operate on
stale pointers.
An attacker within WiFi radio range can exploit this by sending
crafted 802.11 fragmented frames. No authentication is required.
Check the return values of recvframe_pull() and recvframe_pull_tail(),
then verify that the fragment payload fits within the remaining
buffer space before the memcpy(). Consolidate the five cleanup
paths through a single out_err label.
Found by reviewing memory operations in the driver and tracing
buffer pointer manipulation through rtw_recv.h inline helpers.
Not tested on hardware.
Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org
Signed-off-by: Delene Tchio Romuald <delenetchior1@gmail.com>
---
v6: restore the '/* memcpy */' comment that v5 had removed
as drive-by cleanup (Dan Carpenter).
v5: collapse the identical cleanup sites into a single
out_err label (Dan Carpenter).
v4: check return values of recvframe_pull() and
recvframe_pull_tail(); drop unnecessary (uint) cast;
add Fixes: tag and Cc: stable (Dan Carpenter).
v3: rebased on staging-next; sent as numbered series with
proper Cc from get_maintainer.pl.
v2: rebased on staging-next (v1 was based on v7.0-rc6 and
did not apply).
drivers/staging/rtl8723bs/core/rtw_recv.c | 36 ++++++++++++-----------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index f78194d508dfc..8d5d9a6dc4db0 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1090,14 +1090,9 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter,
pfhdr = &prframe->u.hdr;
list_del_init(&(prframe->u.list));
- if (curfragnum != pfhdr->attrib.frag_num) {
- /* the first fragment number must be 0 */
- /* free the whole queue */
- rtw_free_recvframe(prframe, pfree_recv_queue);
- rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
-
- return NULL;
- }
+ /* the first fragment number must be 0 */
+ if (curfragnum != pfhdr->attrib.frag_num)
+ goto out_err;
curfragnum++;
@@ -1112,13 +1107,9 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter,
/* check the fragment sequence (2nd ~n fragment frame) */
- if (curfragnum != pnfhdr->attrib.frag_num) {
- /* the fragment number must be increasing (after decache) */
- /* release the defrag_q & prframe */
- rtw_free_recvframe(prframe, pfree_recv_queue);
- rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
- return NULL;
- }
+ /* the fragment number must be increasing (after decache) */
+ if (curfragnum != pnfhdr->attrib.frag_num)
+ goto out_err;
curfragnum++;
@@ -1127,10 +1118,16 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter,
wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
- recvframe_pull(pnextrframe, wlanhdr_offset);
+ if (!recvframe_pull(pnextrframe, wlanhdr_offset))
+ goto out_err;
/* append to first fragment frame's tail (if privacy frame, pull the ICV) */
- recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
+ if (!recvframe_pull_tail(prframe, pfhdr->attrib.icv_len))
+ goto out_err;
+
+ /* Verify the receiving buffer has enough space for the fragment */
+ if (pnfhdr->len > pfhdr->rx_end - pfhdr->rx_tail)
+ goto out_err;
/* memcpy */
memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
@@ -1146,6 +1143,11 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter,
rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
return prframe;
+
+out_err:
+ rtw_free_recvframe(prframe, pfree_recv_queue);
+ rtw_free_recvframe_queue(defrag_q, pfree_recv_queue);
+ return NULL;
}
/* check if need to defrag, if needed queue the frame to defrag_q */
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v6 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
@ 2026-04-17 6:10 ` Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl() Delene Tchio Romuald
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 6:10 UTC (permalink / raw)
To: gregkh
Cc: error27, luka.gejak, hansg, linux-staging, linux-kernel, stable,
Delene Tchio Romuald
In recvframe_chkmic(), the payload length is computed as:
datalen = precvframe->u.hdr.len - prxattrib->hdrlen
- prxattrib->iv_len - prxattrib->icv_len - 8;
All operands are unsigned. If the receive frame is shorter than the
sum of the header, IV, ICV and MIC sizes, this subtraction wraps
around and datalen becomes a huge unsigned value. That value is then
passed to rtw_secmicappend(), which reads past the end of the
receive buffer and can leak kernel memory or trigger a crash.
An attacker within WiFi radio range can exploit this by sending a
crafted short TKIP-encrypted frame. No authentication is required.
Validate that the frame is large enough for the TKIP MIC
computation before the subtraction.
Found by reviewing length arithmetic in the TKIP receive path.
Not tested on hardware.
Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Signed-off-by: Delene Tchio Romuald <delenetchior1@gmail.com>
---
v6: unchanged.
v5: unchanged.
v4: add Fixes: tag and Cc: stable (Dan Carpenter); carry
Luka Gejak's Reviewed-by.
v3: rebased on staging-next; sent as numbered series with
proper Cc from get_maintainer.pl.
v2: rebased on staging-next (v1 was based on v7.0-rc6 and
did not apply).
drivers/staging/rtl8723bs/core/rtw_recv.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 8d5d9a6dc4db0..e30617875a69d 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -390,6 +390,13 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p
mickey = &stainfo->dot11tkiprxmickey.skey[0];
}
+ /* Ensure the frame is large enough for TKIP MIC verification */
+ if (precvframe->u.hdr.len <= prxattrib->hdrlen +
+ prxattrib->iv_len + prxattrib->icv_len + 8) {
+ res = _FAIL;
+ goto exit;
+ }
+
datalen = precvframe->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len - prxattrib->icv_len - 8;/* icv_len included the mic code */
pframe = precvframe->u.hdr.rx_data;
payload = pframe + prxattrib->hdrlen + prxattrib->iv_len;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v6 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl()
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification Delene Tchio Romuald
@ 2026-04-17 6:10 ` Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions Delene Tchio Romuald
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 6:10 UTC (permalink / raw)
To: gregkh
Cc: error27, luka.gejak, hansg, linux-staging, linux-kernel, stable,
Delene Tchio Romuald
In portctrl(), when 802.1X port control is enabled and a non-EAPOL
frame is received, the ether_type is read from the LLC header
without verifying that the frame actually contains enough bytes to
hold the MAC header, IV and the LLC header plus two bytes of
ether_type. For sufficiently short frames, the memcpy() that loads
be_tmp reads past the end of the receive buffer.
An attacker within WiFi radio range can exploit this by sending a
crafted short frame. No authentication is required.
Validate the frame length before dereferencing the LLC header; drop
the frame if it is too short.
Found by reviewing length validation in the receive path.
Not tested on hardware.
Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org
Signed-off-by: Delene Tchio Romuald <delenetchior1@gmail.com>
---
v6: drop the unrelated cleanups (ptr = ptr + X -> ptr += X,
ether_type inversion into direct return NULL); the patch
now only adds the short-frame length check before
dereferencing the LLC header (Dan Carpenter).
v5: return NULL directly on the short-frame and non-EAPOL
error paths (Dan Carpenter).
v4: add Fixes: tag and Cc: stable (Dan Carpenter).
v3: rebased on staging-next; sent as numbered series with
proper Cc from get_maintainer.pl.
v2: rebased on staging-next (v1 was based on v7.0-rc6 and
did not apply).
drivers/staging/rtl8723bs/core/rtw_recv.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index e30617875a69d..b476f7a03a234 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -539,6 +539,14 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre
prtnframe = precv_frame;
+ /* Ensure frame has LLC header and ether_type */
+ if (pfhdr->len < pattrib->hdrlen +
+ pattrib->iv_len + LLC_HEADER_LENGTH + 2) {
+ rtw_free_recvframe(precv_frame,
+ &adapter->recvpriv.free_recv_queue);
+ return NULL;
+ }
+
/* get ether_type */
ptr = ptr + pfhdr->attrib.hdrlen + pfhdr->attrib.iv_len + LLC_HEADER_LENGTH;
memcpy(&be_tmp, ptr, 2);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v6 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (2 preceding siblings ...)
2026-04-17 6:10 ` [PATCH v6 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl() Delene Tchio Romuald
@ 2026-04-17 6:10 ` Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 5/5] staging: rtl8723bs: fix negative length in WEP decryption Delene Tchio Romuald
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 6:10 UTC (permalink / raw)
To: gregkh
Cc: error27, luka.gejak, hansg, linux-staging, linux-kernel, stable,
Delene Tchio Romuald
rtw_get_wapi_ie(), rtw_get_sec_ie() and rtw_get_wps_ie() walk a
buffer of Information Elements using the TLV length field without
first verifying that the length byte itself is inside the buffer,
and without verifying that the specific bytes dereferenced by the
subsequent memcmp() calls fit inside the declared element.
An attacker within WiFi radio range can exploit this by sending
crafted beacon or probe-response frames carrying truncated or
oversized IEs. No authentication is required.
Ensure the length byte is inside the buffer (cnt + 1 < in_len),
break out of the loop if the declared element length would read
past in_len, and before each memcmp() verify that the offsets it
touches are inside the buffer: cnt + 10 for the WAPI OUI compared
at offset 6, and cnt + 6 for the WPA/WPS OUIs compared at offset 2.
Found by reviewing bounds checks in IE walkers.
Not tested on hardware.
Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org
Signed-off-by: Delene Tchio Romuald <delenetchior1@gmail.com>
---
v6: unchanged.
v5: add an inner bound check before each memcmp() so that
the OUI read at offset 6 (WAPI) or offset 2 (WPA/WPS)
stays inside the declared element (Dan Carpenter).
v4: add Fixes: tag and Cc: stable (Dan Carpenter).
v3: rebased on staging-next; sent as numbered series with
proper Cc from get_maintainer.pl.
v2: rebased on staging-next (v1 was based on v7.0-rc6 and
did not apply).
.../staging/rtl8723bs/core/rtw_ieee80211.c | 70 +++++++++++++------
1 file changed, 47 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
index 72b7f731dd471..1b61879acb48e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -582,18 +582,25 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len)
cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
- while (cnt < in_len) {
+ while (cnt + 1 < in_len) {
authmode = in_ie[cnt];
- if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY &&
- (!memcmp(&in_ie[cnt + 6], wapi_oui1, 4) ||
- !memcmp(&in_ie[cnt + 6], wapi_oui2, 4))) {
- if (wapi_ie)
- memcpy(wapi_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
+ if (cnt + 2 + in_ie[cnt + 1] > in_len)
+ break;
+
+ if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY) {
+ if (cnt + 10 > in_len)
+ break;
- if (wapi_len)
- *wapi_len = in_ie[cnt + 1] + 2;
+ if (!memcmp(&in_ie[cnt + 6], wapi_oui1, 4) ||
+ !memcmp(&in_ie[cnt + 6], wapi_oui2, 4)) {
+ if (wapi_ie)
+ memcpy(wapi_ie, &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
+ if (wapi_len)
+ *wapi_len = in_ie[cnt + 1] + 2;
+ }
}
cnt += in_ie[cnt + 1] + 2; /* get next */
@@ -615,15 +622,23 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie
cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
- while (cnt < in_len) {
+ while (cnt + 1 < in_len) {
authmode = in_ie[cnt];
- if ((authmode == WLAN_EID_VENDOR_SPECIFIC) &&
- (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) {
- if (wpa_ie)
- memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
+ if (cnt + 2 + in_ie[cnt + 1] > in_len)
+ break;
+
+ if (authmode == WLAN_EID_VENDOR_SPECIFIC) {
+ if (cnt + 6 > in_len)
+ break;
+
+ if (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4)) {
+ if (wpa_ie)
+ memcpy(wpa_ie, &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
- *wpa_len = in_ie[cnt + 1] + 2;
+ *wpa_len = in_ie[cnt + 1] + 2;
+ }
} else if (authmode == WLAN_EID_RSN) {
if (rsn_ie)
memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
@@ -658,21 +673,30 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
cnt = 0;
- while (cnt < in_len) {
+ while (cnt + 1 < in_len) {
eid = in_ie[cnt];
- if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) {
- wpsie_ptr = &in_ie[cnt];
+ if (cnt + 2 + in_ie[cnt + 1] > in_len)
+ break;
- if (wps_ie)
- memcpy(wps_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
+ if (eid == WLAN_EID_VENDOR_SPECIFIC) {
+ if (cnt + 6 > in_len)
+ break;
- if (wps_ielen)
- *wps_ielen = in_ie[cnt + 1] + 2;
+ if (!memcmp(&in_ie[cnt + 2], wps_oui, 4)) {
+ wpsie_ptr = &in_ie[cnt];
- cnt += in_ie[cnt + 1] + 2;
+ if (wps_ie)
+ memcpy(wps_ie, &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
- break;
+ if (wps_ielen)
+ *wps_ielen = in_ie[cnt + 1] + 2;
+
+ cnt += in_ie[cnt + 1] + 2;
+
+ break;
+ }
}
cnt += in_ie[cnt + 1] + 2; /* goto next */
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v6 5/5] staging: rtl8723bs: fix negative length in WEP decryption
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (3 preceding siblings ...)
2026-04-17 6:10 ` [PATCH v6 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions Delene Tchio Romuald
@ 2026-04-17 6:10 ` Delene Tchio Romuald
2026-04-17 6:44 ` [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Dan Carpenter
2026-04-17 7:26 ` Luka Gejak
6 siblings, 0 replies; 8+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 6:10 UTC (permalink / raw)
To: gregkh
Cc: error27, luka.gejak, hansg, linux-staging, linux-kernel, stable,
Delene Tchio Romuald
In rtw_wep_decrypt(), the payload length is computed as:
length = frame->len - prxattrib->hdrlen - prxattrib->iv_len;
All operands are unsigned. If the frame is shorter than the sum of
the header length, IV length and the 4-byte ICV, this subtraction
wraps around or produces a value smaller than 4; the subsequent
crc32_le(~0, payload, length - 4) call then wraps length - 4 to a
huge value and reads past the end of the receive buffer.
An attacker within WiFi radio range can exploit this by sending a
crafted short WEP-encrypted frame. No authentication is required.
Validate that the frame is large enough to contain at least the
4-byte ICV on top of the header and IV before computing length.
Found by reviewing length arithmetic in the WEP decrypt path.
Not tested on hardware.
Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver")
Cc: stable@vger.kernel.org
Signed-off-by: Delene Tchio Romuald <delenetchior1@gmail.com>
---
v6: unchanged.
v5: tighten the length check to also cover the 4-byte ICV
so that the subsequent crc32_le(payload, length - 4)
call cannot underflow length - 4.
v4: add Fixes: tag and Cc: stable (Dan Carpenter).
v3: rebased on staging-next; sent as numbered series with
proper Cc from get_maintainer.pl.
v2: rebased on staging-next (v1 was based on v7.0-rc6 and
did not apply).
drivers/staging/rtl8723bs/core/rtw_security.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index a00504ff29109..ddd6ed2245035 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -113,6 +113,12 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
memcpy(&wepkey[0], iv, 3);
/* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */
memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength);
+
+ /* Ensure the frame is long enough for WEP payload and ICV */
+ if (((union recv_frame *)precvframe)->u.hdr.len <
+ prxattrib->hdrlen + prxattrib->iv_len + 4)
+ return;
+
length = ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (4 preceding siblings ...)
2026-04-17 6:10 ` [PATCH v6 5/5] staging: rtl8723bs: fix negative length in WEP decryption Delene Tchio Romuald
@ 2026-04-17 6:44 ` Dan Carpenter
2026-04-17 7:26 ` Luka Gejak
6 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2026-04-17 6:44 UTC (permalink / raw)
To: Delene Tchio Romuald
Cc: gregkh, luka.gejak, hansg, linux-staging, linux-kernel, stable
Thanks!
Reviewed-by: Dan Carpenter <error27@gmail.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (5 preceding siblings ...)
2026-04-17 6:44 ` [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Dan Carpenter
@ 2026-04-17 7:26 ` Luka Gejak
6 siblings, 0 replies; 8+ messages in thread
From: Luka Gejak @ 2026-04-17 7:26 UTC (permalink / raw)
To: Delene Tchio Romuald, gregkh
Cc: error27, hansg, linux-staging, linux-kernel, stable, luka.gejak
On April 17, 2026 8:10:43 AM GMT+02:00, Delene Tchio Romuald <delenetchior1@gmail.com> wrote:
>This series fixes five remotely-triggerable memory safety issues in
>the rtl8723bs driver. All of them are reachable from the air by an
>attacker within WiFi radio range, without authentication, via
>crafted management or data frames:
>
LGTM.
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-17 7:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17 6:10 [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl() Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions Delene Tchio Romuald
2026-04-17 6:10 ` [PATCH v6 5/5] staging: rtl8723bs: fix negative length in WEP decryption Delene Tchio Romuald
2026-04-17 6:44 ` [PATCH v6 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Dan Carpenter
2026-04-17 7:26 ` Luka Gejak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox