Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH rtw-next] wifi: rtw88: usb: reject oversized RX packets
@ 2026-11-28  5:54 Maoyi Xie
  2026-11-28 12:47 ` Luka Gejak
  0 siblings, 1 reply; 2+ messages in thread
From: Maoyi Xie @ 2026-11-28  5:54 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: linux-wireless, Bitterblue Smith

rtw_usb_rx_handler() checks pkt_len + pkt_offset of each aggregated RX
packet only against max_skb_len. If a corrupted descriptor claims more
than the bytes left in the URB, skb_put_data() reads up to about 11 KB
past the received data.

Stop the walk when a packet does not fit in the rest of the URB.

Found with a CodeQL-based static analysis tool that we are developing.
Reproduced in a userspace harness under AddressSanitizer. Not tested on
hardware.

Fixes: e9048e2935f7 ("wifi: rtw88: usb: Copy instead of cloning the RX skb")
Cc: stable@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.

Commit 83ca360e8528 ("wifi: rtw88: sdio: reject oversized RX packets")
added the same check. The rtw89 USB RX handler also drops such a packet.

 drivers/net/wireless/realtek/rtw88/usb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
index 7b1fc7ef10a0..ef2a0686b7cf 100644
--- a/drivers/net/wireless/realtek/rtw88/usb.c
+++ b/drivers/net/wireless/realtek/rtw88/usb.c
@@ -718,6 +718,13 @@ static void rtw_usb_rx_handler(struct work_struct *work)
 				goto skip_packet;
 			}
 
+			if (unlikely(rx_desc + skb_len > rx_skb->data + rx_skb->len)) {
+				rtw_dbg(rtwdev, RTW_DBG_USB,
+					"oversized RX packet: %u, %td bytes left\n",
+					skb_len, rx_skb->data + rx_skb->len - rx_desc);
+				break;
+			}
+
 			skb = alloc_skb(skb_len, GFP_ATOMIC);
 			if (!skb) {
 				rtw_dbg(rtwdev, RTW_DBG_USB,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-28 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28  5:54 [PATCH rtw-next] wifi: rtw88: usb: reject oversized RX packets Maoyi Xie
2026-11-28 12:47 ` Luka Gejak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox