* [PATCH net] rsi: stop thread firstly in rsi_91x_init() error handling
@ 2021-10-15 4:03 Ziyang Xuan
2021-10-20 8:40 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Ziyang Xuan @ 2021-10-15 4:03 UTC (permalink / raw)
To: amitkarwar, siva8118
Cc: kvalo, davem, kuba, linux-wireless, netdev, linux-kernel
When fail to init coex module, free 'common' and 'adapter' directly, but
common->tx_thread which will access 'common' and 'adapter' is running at
the same time. That will trigger the UAF bug.
==================================================================
BUG: KASAN: use-after-free in rsi_tx_scheduler_thread+0x50f/0x520 [rsi_91x]
Read of size 8 at addr ffff8880076dc000 by task Tx-Thread/124777
CPU: 0 PID: 124777 Comm: Tx-Thread Not tainted 5.15.0-rc5+ #19
Call Trace:
dump_stack_lvl+0xe2/0x152
print_address_description.constprop.0+0x21/0x140
? rsi_tx_scheduler_thread+0x50f/0x520
kasan_report.cold+0x7f/0x11b
? rsi_tx_scheduler_thread+0x50f/0x520
rsi_tx_scheduler_thread+0x50f/0x520
...
Freed by task 111873:
kasan_save_stack+0x1b/0x40
kasan_set_track+0x1c/0x30
kasan_set_free_info+0x20/0x30
__kasan_slab_free+0x109/0x140
kfree+0x117/0x4c0
rsi_91x_init+0x741/0x8a0 [rsi_91x]
rsi_probe+0x9f/0x1750 [rsi_usb]
Stop thread before free 'common' and 'adapter' to fix it.
Fixes: 2108df3c4b18 ("rsi: add coex support")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
drivers/net/wireless/rsi/rsi_91x_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wireless/rsi/rsi_91x_main.c b/drivers/net/wireless/rsi/rsi_91x_main.c
index d98483298555..87f83def6c25 100644
--- a/drivers/net/wireless/rsi/rsi_91x_main.c
+++ b/drivers/net/wireless/rsi/rsi_91x_main.c
@@ -359,6 +359,7 @@ struct rsi_hw *rsi_91x_init(u16 oper_mode)
if (common->coex_mode > 1) {
if (rsi_coex_attach(common)) {
rsi_dbg(ERR_ZONE, "Failed to init coex module\n");
+ rsi_kill_thread(&common->tx_thread);
goto err;
}
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] rsi: stop thread firstly in rsi_91x_init() error handling
2021-10-15 4:03 [PATCH net] rsi: stop thread firstly in rsi_91x_init() error handling Ziyang Xuan
@ 2021-10-20 8:40 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2021-10-20 8:40 UTC (permalink / raw)
To: Ziyang Xuan
Cc: amitkarwar, siva8118, davem, kuba, linux-wireless, netdev, linux-kernel
Ziyang Xuan <william.xuanziyang@huawei.com> wrote:
> When fail to init coex module, free 'common' and 'adapter' directly, but
> common->tx_thread which will access 'common' and 'adapter' is running at
> the same time. That will trigger the UAF bug.
>
> ==================================================================
> BUG: KASAN: use-after-free in rsi_tx_scheduler_thread+0x50f/0x520 [rsi_91x]
> Read of size 8 at addr ffff8880076dc000 by task Tx-Thread/124777
> CPU: 0 PID: 124777 Comm: Tx-Thread Not tainted 5.15.0-rc5+ #19
> Call Trace:
> dump_stack_lvl+0xe2/0x152
> print_address_description.constprop.0+0x21/0x140
> ? rsi_tx_scheduler_thread+0x50f/0x520
> kasan_report.cold+0x7f/0x11b
> ? rsi_tx_scheduler_thread+0x50f/0x520
> rsi_tx_scheduler_thread+0x50f/0x520
> ...
>
> Freed by task 111873:
> kasan_save_stack+0x1b/0x40
> kasan_set_track+0x1c/0x30
> kasan_set_free_info+0x20/0x30
> __kasan_slab_free+0x109/0x140
> kfree+0x117/0x4c0
> rsi_91x_init+0x741/0x8a0 [rsi_91x]
> rsi_probe+0x9f/0x1750 [rsi_usb]
>
> Stop thread before free 'common' and 'adapter' to fix it.
>
> Fixes: 2108df3c4b18 ("rsi: add coex support")
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Patch applied to wireless-drivers-next.git, thanks.
515e7184bdf0 rsi: stop thread firstly in rsi_91x_init() error handling
--
https://patchwork.kernel.org/project/linux-wireless/patch/20211015040335.1021546-1-william.xuanziyang@huawei.com/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-20 8:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 4:03 [PATCH net] rsi: stop thread firstly in rsi_91x_init() error handling Ziyang Xuan
2021-10-20 8:40 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).