From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794585339; b=1YNFcq+jCMIrztdkU0qxgf/Au/NWFS382SnrhndDB+6bZyjos3VpUedTQ2yq3fUzA+f6 YQv3aUdTbepUrvzOImOopf1WoyReyCEDottKQrx7f0aciw0fDVE1bT0a4MhCUEWSQJTsZ Vm+y96aEuy/CpdIxlmIYybQA5dxUUsFnmrDeOtOobYc9EypMvbDaDb/0c5IAx5x9N3WGX M6bW3zKrF6ygOs67z43yQsJfAMBoEBi2T2UyChRgXFRGOHSej+n3g0IXGx1Hsmiyx/9am 7arU7aLiBAQeu6dhDnuvm0blXzWz8HxWF5df0DbBJpjKLFPmW+WCctn/i9sSU83LV0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794585339; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=TYkgDKf3sLXX1AnEcTPSevVtIO567LPTALhOc8xR22c=; b=xX2SdeDo9Q0my7AsnB3pKGWknXFleNQdITCksVzYFwh843udCuip795Gs33BE+mo0Evt VjnBe3YvcgVJAxKCLlrYGVpupuwLgpbmcxW+Bm4QeRog0LdqgwuBs4laEKAiJaHKXmB8A fjrVQ/lX2ynPMOoDtZ6sW/QjPyU47CrveWlE62UAUzIaH86vZZ5EvpQWFKJmcqbOvRhce Kd4cI6DDhz/yZ1OlE9yq5PJq2BjaqzUwwA1CvS5DLyn8jqtng6n5uGu36MI5tMPmAzJkH Iq2FIPEBwEaX3OOW3XjVNfMsWI0q3ITbFuSz/feeDs4h/CeMiwkiMxsEoFZBmzCquEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Sy+334ya; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B175760A2625; Fri, 13 Nov 2026 15:55:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Sy+334ya Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D06C1F000D3; Fri, 13 Nov 2026 15:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794585339; bh=TYkgDKf3sLXX1AnEcTPSevVtIO567LPTALhOc8xR22c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Sy+334yaTrdTIhBVQwQxDe8fbUHMIQEbl5uQpcA7PU17inNIKjcnb8otzz0ZxZjT5 9OU7aYxgIt5pWTMGguakhTe7VKEVBri3QfJOAgd9Z2L+KZ4S8woTHzSq1TDYe9jemM fMzr7sEFtHDWVY40RhW84qP68py59f62QRpaIVw8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+675af112519ca34f5502@syzkaller.appspotmail.com, Shuai Liu <847807867@qq.com>, Jens Axboe , Sasha Levin Subject: [PATCH 7.3 024/507] io_uring/sqpoll: dont set IO_SQ_THREAD_SHOULD_STOP on thread exit Date: Fri, 13 Nov 2026 10:45:28 -0500 Message-ID: <20261113153754.203776023@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261113153753.358973689@linuxfoundation.org> References: <20261113153753.358973689@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuai Liu <847807867@qq.com> Commit fca3ff9e2eee7d285585daf51942e0b5e2be354a upstream. io_sq_thread_stop() carries a WARN_ON_ONCE() asserting that IO_SQ_THREAD_SHOULD_STOP isn't set yet, i.e. that stopping the SQPOLL thread is never attempted twice. Since commit 22d9db9fd64a ("io_uring/sqpoll: don't attach to a thread that is canceling"), the SQPOLL thread itself sets that bit on its way out, so that io_sq_offload_create() won't attach a new ring to a thread that is canceling. When the thread exits on a fatal signal, the bit is thus set before the ring teardown gets to io_sq_thread_stop(), which now triggers the warning on every such exit: WARNING: io_uring/sqpoll.c:88 at io_sq_thread_stop Workqueue: iou_exit io_ring_exit_work Call Trace: io_put_sq_data io_sq_thread_finish io_ring_ctx_free io_ring_exit_work Introduce a separate IO_SQ_THREAD_EXITING bit for the thread marking itself as on its way out, and check it in io_sq_offload_create() along with IO_SQ_THREAD_SHOULD_STOP. IO_SQ_THREAD_SHOULD_STOP regains its original meaning, "a stop has been requested", and the WARN_ON_ONCE() holds again. Reproduced with an SQPOLL ring and an immediate fatal signal: the warning fires on v7.3.0+ (22d9db9fd64a present) and is gone with this change. Reported-by: syzbot+675af112519ca34f5502@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=675af112519ca34f5502 Fixes: 22d9db9fd64a ("io_uring/sqpoll: don't attach to a thread that is canceling") Signed-off-by: Shuai Liu <847807867@qq.com> Link: https://patch.msgid.link/tencent_BB08960D79E0261B5C1EB1E589787734E907@qq.com [axboe: trim excessive comment] Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- io_uring/sqpoll.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index c833e776320d4..e86658ede44be 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -29,6 +29,7 @@ enum { IO_SQ_THREAD_SHOULD_STOP = 0, IO_SQ_THREAD_SHOULD_PARK, + IO_SQ_THREAD_EXITING, }; void io_sq_thread_unpark(struct io_sq_data *sqd) @@ -436,9 +437,10 @@ static int io_sq_thread(void *data) /* * Cancelation drops sqd->lock while it waits, and a ring could attach * to a thread that is on its way out. A fatal signal doesn't set the - * bit, so set it here for io_sq_offload_create() to see. + * stop bit, so mark the thread as exiting here for + * io_sq_offload_create() to see. */ - set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state); + set_bit(IO_SQ_THREAD_EXITING, &sqd->state); io_uring_cancel_generic(true, sqd); rcu_assign_pointer(sqd->thread, NULL); put_task_struct(current); @@ -510,7 +512,8 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx, /* don't attach to a dying SQPOLL thread, would be racy */ ret = 0; if (attached && (!sqd->thread || - test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state))) + test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state) || + test_bit(IO_SQ_THREAD_EXITING, &sqd->state))) ret = -ENXIO; io_sq_thread_unpark(sqd); -- 2.53.0