* [PATCH v5 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag()
2026-04-17 3:01 [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
@ 2026-04-17 3:01 ` Delene Tchio Romuald
2026-04-17 5:31 ` Dan Carpenter
2026-04-17 3:01 ` [PATCH v5 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification Delene Tchio Romuald
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 3:01 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>
---
v5: collapse the five 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 | 37 ++++++++++++-----------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index f78194d508dfc..52d029c28ab1f 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,12 +1118,17 @@ 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);
recvframe_put(prframe, pnfhdr->len);
@@ -1146,6 +1142,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] 9+ messages in thread* Re: [PATCH v5 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag()
2026-04-17 3:01 ` [PATCH v5 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
@ 2026-04-17 5:31 ` Dan Carpenter
0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2026-04-17 5:31 UTC (permalink / raw)
To: Delene Tchio Romuald
Cc: gregkh, luka.gejak, hansg, linux-staging, linux-kernel, stable
On Fri, Apr 17, 2026 at 04:01:06AM +0100, Delene Tchio Romuald wrote:
> + /* Verify the receiving buffer has enough space for the fragment */
> + if (pnfhdr->len > pfhdr->rx_end - pfhdr->rx_tail)
> + goto out_err;
>
> - /* memcpy */
I wasn't going to mention this, but since you're going to need to
resend anyway... Yes, this comment is useless but don't delete it
as part of a security fix. It's unrelated.
regards,
dan carpenter
> memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
>
> recvframe_put(prframe, pnfhdr->len);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification
2026-04-17 3:01 [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
2026-04-17 3:01 ` [PATCH v5 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
@ 2026-04-17 3:01 ` Delene Tchio Romuald
2026-04-17 3:01 ` [PATCH v5 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl() Delene Tchio Romuald
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 3:01 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>
---
v5: unchanged; carry Luka Gejak's Reviewed-by.
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 52d029c28ab1f..40884788a30d6 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] 9+ messages in thread* [PATCH v5 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl()
2026-04-17 3:01 [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
2026-04-17 3:01 ` [PATCH v5 1/5] staging: rtl8723bs: fix heap buffer overflow in recvframe_defrag() Delene Tchio Romuald
2026-04-17 3:01 ` [PATCH v5 2/5] staging: rtl8723bs: fix integer underflow in TKIP MIC verification Delene Tchio Romuald
@ 2026-04-17 3:01 ` Delene Tchio Romuald
2026-04-17 5:35 ` Dan Carpenter
2026-04-17 3:01 ` [PATCH v5 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions Delene Tchio Romuald
` (2 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 3:01 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 and
return early on short frames and on non-EAPOL frames, rather than
staging the result in prtnframe.
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>
---
v5: return NULL directly on the short-frame and non-EAPOL
error paths instead of staging the result through
prtnframe (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 | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index 40884788a30d6..b11982fbe7e1f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -537,20 +537,25 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre
/* blocked */
/* only accept EAPOL frame */
- 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;
+ ptr += pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_LENGTH;
memcpy(&be_tmp, ptr, 2);
ether_type = ntohs(be_tmp);
- if (ether_type == eapol_type)
- prtnframe = precv_frame;
- else {
- /* free this frame */
- rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue);
- prtnframe = NULL;
+ if (ether_type != eapol_type) {
+ rtw_free_recvframe(precv_frame,
+ &adapter->recvpriv.free_recv_queue);
+ return NULL;
}
+ prtnframe = precv_frame;
} else {
/* allowed */
/* check decryption status, and decrypt the frame if needed */
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v5 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl()
2026-04-17 3:01 ` [PATCH v5 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl() Delene Tchio Romuald
@ 2026-04-17 5:35 ` Dan Carpenter
0 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2026-04-17 5:35 UTC (permalink / raw)
To: Delene Tchio Romuald
Cc: gregkh, luka.gejak, hansg, linux-staging, linux-kernel, stable
On Fri, Apr 17, 2026 at 04:01:08AM +0100, Delene Tchio Romuald wrote:
> drivers/staging/rtl8723bs/core/rtw_recv.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> index 40884788a30d6..b11982fbe7e1f 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> @@ -537,20 +537,25 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre
> /* blocked */
> /* only accept EAPOL frame */
>
> - 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;
> + ptr += pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_LENGTH;
Don't do this unrelated cleanup.
> memcpy(&be_tmp, ptr, 2);
> ether_type = ntohs(be_tmp);
>
> - if (ether_type == eapol_type)
> - prtnframe = precv_frame;
> - else {
> - /* free this frame */
> - rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue);
> - prtnframe = NULL;
> + if (ether_type != eapol_type) {
> + rtw_free_recvframe(precv_frame,
> + &adapter->recvpriv.free_recv_queue);
> + return NULL;
> }
> + prtnframe = precv_frame;
Same. If you really want to do it, it has to be in a separate patch.
regards,
dan carpenter
> } else {
> /* allowed */
> /* check decryption status, and decrypt the frame if needed */
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions
2026-04-17 3:01 [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (2 preceding siblings ...)
2026-04-17 3:01 ` [PATCH v5 3/5] staging: rtl8723bs: fix out-of-bounds read in portctrl() Delene Tchio Romuald
@ 2026-04-17 3:01 ` Delene Tchio Romuald
2026-04-17 3:01 ` [PATCH v5 5/5] staging: rtl8723bs: fix negative length in WEP decryption Delene Tchio Romuald
2026-04-17 5:35 ` [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Dan Carpenter
5 siblings, 0 replies; 9+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 3:01 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>
---
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] 9+ messages in thread* [PATCH v5 5/5] staging: rtl8723bs: fix negative length in WEP decryption
2026-04-17 3:01 [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (3 preceding siblings ...)
2026-04-17 3:01 ` [PATCH v5 4/5] staging: rtl8723bs: fix out-of-bounds reads in IE parsing functions Delene Tchio Romuald
@ 2026-04-17 3:01 ` Delene Tchio Romuald
2026-04-17 5:35 ` [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Dan Carpenter
5 siblings, 0 replies; 9+ messages in thread
From: Delene Tchio Romuald @ 2026-04-17 3:01 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>
---
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] 9+ messages in thread* Re: [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities
2026-04-17 3:01 [PATCH v5 0/5] staging: rtl8723bs: fix multiple security vulnerabilities Delene Tchio Romuald
` (4 preceding siblings ...)
2026-04-17 3:01 ` [PATCH v5 5/5] staging: rtl8723bs: fix negative length in WEP decryption Delene Tchio Romuald
@ 2026-04-17 5:35 ` Dan Carpenter
5 siblings, 0 replies; 9+ messages in thread
From: Dan Carpenter @ 2026-04-17 5:35 UTC (permalink / raw)
To: Delene Tchio Romuald
Cc: gregkh, luka.gejak, hansg, linux-staging, linux-kernel, stable
Sorry, we're really strict on the "no unrelated changes" rule. Otherwise
it looks good. Thanks!
regards,
dan carpenter
^ permalink raw reply [flat|nested] 9+ messages in thread