Skip to content

Commit 4f9a4ae

Browse files
name2965gregkh
authored andcommitted
wifi: rsi: fix kthread lifetime race between self-exit and external-stop
commit db57a1a upstream. RSI driver use both self-exit(kthread_complete_and_exit) and external-stop (kthread_stop) when killing a kthread. Generally, kthread_stop() is called first, and in this case, no particular issues occur. However, in rare instances where kthread_complete_and_exit() is called first and then kthread_stop() is called, a UAF occurs because the kthread object, which has already exited and been freed, is accessed again. Therefore, to prevent this with minimal modification, you must remove kthread_stop() and change the code to wait until the self-exit operation is completed. Cc: <stable@vger.kernel.org> Reported-by: syzbot+5de83f57cd8531f55596@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/69e5d03b.a00a0220.1bd0ca.0064.GAE@google.com/ Fixes: 4c62764 ("rsi: improve kernel thread handling to fix kernel panic") Signed-off-by: Jeongjun Park <aha310510@gmail.com> Link: https://patch.msgid.link/20260422173846.37640-1-aha310510@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e131562 commit 4f9a4ae

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/net/wireless/rsi/rsi_common.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,11 @@ static inline int rsi_create_kthread(struct rsi_common *common,
7070
return 0;
7171
}
7272

73-
static inline int rsi_kill_thread(struct rsi_thread *handle)
73+
static inline void rsi_kill_thread(struct rsi_thread *handle)
7474
{
7575
atomic_inc(&handle->thread_done);
7676
rsi_set_event(&handle->event);
77-
78-
return kthread_stop(handle->task);
77+
wait_for_completion(&handle->completion);
7978
}
8079

8180
void rsi_mac80211_detach(struct rsi_hw *hw);

0 commit comments

Comments
 (0)