From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F25721E098; Sat, 30 May 2026 18:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166005; cv=none; b=QtmZzXz94Dd5wwc41AhdTwkDT3xcy5vw04yqzBUrJ8oCUaGwJ2IU5eB26cuPn5M8V2dY79kM5kHrsytdNxyetr+xWI7dwAD/0PxC0oynudYqo+Qj04NcO7E3weMUxXulFbeDvnBcSRfcyYY+2kBLJiEKAewqWIhflWYlmGzn5Q8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780166005; c=relaxed/simple; bh=uDDd97ObWryXMKIoqL7vMSFfl6C7BP7K7bn9+zzI83s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aZpvDQEDg+hGrm0APYFI5t2naP5B5ly9cZ4uan6KqCwT6OuGttyGh/4jV9+QUhFJk+tTQk+ESsbsZWVcG+jiO3GnsH/XctT+byyH4dqb71QFdWnTcLBQK6gvwyNwgpxpw8F19Dp596ul3vBRp5/yhyVoRET42/ukRCQ7hO23J4A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eCtn1Jix; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eCtn1Jix" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FC081F00893; Sat, 30 May 2026 18:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780166004; bh=3mq5SRH8t0cyn3Vv6aag1SGRJlc7hIBpCh89Nlzdyoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eCtn1Jixn+ci3Ov2ccqY5Gn7ZvST9tkmK1madzQ5i7ldZDuT6hmjRrZ1UjxNZQW3M PCn7N/bzNFAzWOpqQEE59Ld8AUrPKn++wdp9hp6S3LC/Np91sJSk62TUIY0dNvdeT1 UDhY7fVXH+il1Swj9W1CNWD2Ar7D9JjzI3CIZeLo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+5de83f57cd8531f55596@syzkaller.appspotmail.com, Jeongjun Park , Johannes Berg Subject: [PATCH 5.10 217/589] wifi: rsi: fix kthread lifetime race between self-exit and external-stop Date: Sat, 30 May 2026 18:01:38 +0200 Message-ID: <20260530160230.680558838@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160224.570625122@linuxfoundation.org> References: <20260530160224.570625122@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeongjun Park commit db57a1aa54ff68669781976e4edb045e09e2b65b 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: Reported-by: syzbot+5de83f57cd8531f55596@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/69e5d03b.a00a0220.1bd0ca.0064.GAE@google.com/ Fixes: 4c62764d0fc2 ("rsi: improve kernel thread handling to fix kernel panic") Signed-off-by: Jeongjun Park Link: https://patch.msgid.link/20260422173846.37640-1-aha310510@gmail.com Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/rsi/rsi_common.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/net/wireless/rsi/rsi_common.h +++ b/drivers/net/wireless/rsi/rsi_common.h @@ -70,12 +70,11 @@ static inline int rsi_create_kthread(str return 0; } -static inline int rsi_kill_thread(struct rsi_thread *handle) +static inline void rsi_kill_thread(struct rsi_thread *handle) { atomic_inc(&handle->thread_done); rsi_set_event(&handle->event); - - return kthread_stop(handle->task); + wait_for_completion(&handle->completion); } void rsi_mac80211_detach(struct rsi_hw *hw);