* [PATCH] wifi: rtw89: usb: cancel TX URBs on probe failure
@ 2026-12-01 20:24 Artem Dinaburg
2026-12-02 1:48 ` Ping-Ke Shih
0 siblings, 1 reply; 4+ messages in thread
From: Artem Dinaburg @ 2026-12-01 20:24 UTC (permalink / raw)
To: pkshih; +Cc: linux-wireless
Chip information setup can leave firmware TX URBs pending when USB probe
fails. The error path then frees the USB private state while those URBs
still reference its TX anchor.
Cancel pending TX URBs before core teardown, as the disconnect path does.
Found and fixed with AI assistance; validated with a KASAN-enabled
kernel build.
Fixes: 26a42d804aa8 ("wifi: rtw89: usb: anchor TX URBs")
Cc: stable@vger.kernel.org
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
---
KASAN report from a USB emulation replay of a failed probe:
rtw89_8852bu ... failed to setup chip information
rtw89_8852bu ... probe with driver rtw89_8852bu failed with error -110
BUG: KASAN: slab-use-after-free in usb_anchor_suspend_wakeups+0x1b/0x30
Write of size 4 ...
A reproducer is available privately on request.
drivers/net/wireless/realtek/rtw89/usb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wireless/realtek/rtw89/usb.c b/drivers/net/wireless/realtek/rtw89/usb.c
index 8dc2c93e502e..38d2a92fb984 100644
--- a/drivers/net/wireless/realtek/rtw89/usb.c
+++ b/drivers/net/wireless/realtek/rtw89/usb.c
@@ -1288,6 +1288,7 @@ int rtw89_usb_probe(struct usb_interface *intf,
return 0;
err_core_deinit:
+ rtw89_usb_cancel_tx_bufs(rtwusb);
rtw89_core_deinit(rtwdev);
err_deinit_rx:
rtw89_usb_deinit_rx(rtwdev);
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* RE: [PATCH] wifi: rtw89: usb: cancel TX URBs on probe failure
2026-12-01 20:24 [PATCH] wifi: rtw89: usb: cancel TX URBs on probe failure Artem Dinaburg
@ 2026-12-02 1:48 ` Ping-Ke Shih
2026-12-02 2:40 ` Artem Dinaburg
0 siblings, 1 reply; 4+ messages in thread
From: Ping-Ke Shih @ 2026-12-02 1:48 UTC (permalink / raw)
To: Artem Dinaburg; +Cc: linux-wireless@vger.kernel.org
Artem Dinaburg <artem@trailofbits.com> wrote:
> Chip information setup can leave firmware TX URBs pending when USB probe
> fails. The error path then frees the USB private state while those URBs
> still reference its TX anchor.
>
> Cancel pending TX URBs before core teardown, as the disconnect path does.
At probe path, there is no transmitting data. How could a TX URBs in flight?
Can you point out which point causes KASAN report?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] wifi: rtw89: usb: cancel TX URBs on probe failure
2026-12-02 1:48 ` Ping-Ke Shih
@ 2026-12-02 2:40 ` Artem Dinaburg
2026-12-02 2:45 ` Ping-Ke Shih
0 siblings, 1 reply; 4+ messages in thread
From: Artem Dinaburg @ 2026-12-02 2:40 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless@vger.kernel.org
Ping-Ke Shih wrote:
> At probe path, there is no transmitting data. How could a TX URBs in flight?
> Can you point out which point causes KASAN report?
Hi Ping-Ke,
This was not a physical device. It was an emulated 8852BU that we built
for testing USB drivers, and it did not complete the bulk-OUT
transfers it was sent.
There is no data traffic during probe, but firmware download goes
through the same TX path and anchors its URBs on tx_submitted:
rtw89_usb_probe()
rtw89_chip_info_setup()
rtw89_chip_efuse_info_setup()
rtw89_mac_partial_init()
rtw89_fw_download() /* up to 5 attempts */
__rtw89_fw_download_hdr()
rtw89_h2c_tx() /* RTW89_TXCH_CH12 */
rtw89_usb_ops_tx_kick_off()
rtw89_usb_write_port() /* usb_anchor_urb(urb,
&rtwusb->tx_submitted) */
Each download attempt timed out with its URB still anchored. After the
five attempts, chip info setup failed and probe went to
err_core_deinit, which frees rtwdev (and rtwusb with it) in
rtw89_free_ieee80211_hw() without killing the anchored URBs. When the
device was then unplugged, usb_hcd_flush_endpoint() gave the pending
URBs back, and __usb_hcd_giveback_urb() called
usb_anchor_suspend_wakeups() on the freed anchor:
rtw89_8852bu 1-1.2:1.0: failed to setup chip information
rtw89_8852bu 1-1.2:1.0: probe with driver rtw89_8852bu failed with error -110
usb 1-1.2: USB disconnect, device number 4
BUG: KASAN: slab-use-after-free in usb_anchor_suspend_wakeups+0x1b/0x30
Write of size 4 at addr ffff88812af926d4 by task kworker/3:0/35
Call Trace:
<IRQ>
usb_anchor_suspend_wakeups+0x1b/0x30
__usb_hcd_giveback_urb+0x1dd/0x3f0
usb_giveback_urb_bh+0x22d/0x540
...
</IRQ>
<TASK>
usb_hcd_flush_endpoint+0xf0/0x250
usb_disable_endpoint+0x198/0x2b0
usb_disable_device_endpoints+0x9e/0x190
usb_disconnect+0x26d/0x940
hub_event+0x24a8/0x40b0
(The memory had been reused before the access, so the "Allocated by"
and "Freed by" stacks in the report belong to the later user, not to
rtw89.)
A working 8852BU completes those transfers, so this should not happen
with real hardware. I sent the fix because it is one line, matches
what rtw89_usb_disconnect() already does, and keeps a device that only
pretends to be an 8852BU from turning a failed probe into a
use-after-free.
Thanks,
Artem Dinaburg
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] wifi: rtw89: usb: cancel TX URBs on probe failure
2026-12-02 2:40 ` Artem Dinaburg
@ 2026-12-02 2:45 ` Ping-Ke Shih
0 siblings, 0 replies; 4+ messages in thread
From: Ping-Ke Shih @ 2026-12-02 2:45 UTC (permalink / raw)
To: Artem Dinaburg; +Cc: linux-wireless@vger.kernel.org
Artem Dinaburg <artem@trailofbits.com> wrote:
> Ping-Ke Shih wrote:
> > At probe path, there is no transmitting data. How could a TX URBs in flight?
> > Can you point out which point causes KASAN report?
>
> Hi Ping-Ke,
>
> This was not a physical device. It was an emulated 8852BU that we built
> for testing USB drivers, and it did not complete the bulk-OUT
> transfers it was sent.
>
> There is no data traffic during probe, but firmware download goes
> through the same TX path and anchors its URBs on tx_submitted:
>
> rtw89_usb_probe()
> rtw89_chip_info_setup()
> rtw89_chip_efuse_info_setup()
> rtw89_mac_partial_init()
> rtw89_fw_download() /* up to 5 attempts */
> __rtw89_fw_download_hdr()
> rtw89_h2c_tx() /* RTW89_TXCH_CH12 */
> rtw89_usb_ops_tx_kick_off()
> rtw89_usb_write_port() /* usb_anchor_urb(urb,
> &rtwusb->tx_submitted) */
>
> Each download attempt timed out with its URB still anchored.
Thanks for the explanation in detail. I missed this point that it might
be timed out during downloading firmware.
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 2:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 20:24 [PATCH] wifi: rtw89: usb: cancel TX URBs on probe failure Artem Dinaburg
2026-12-02 1:48 ` Ping-Ke Shih
2026-12-02 2:40 ` Artem Dinaburg
2026-12-02 2:45 ` Ping-Ke Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox