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=1796379500; b=b6Dg8Z+EwMc/cGnQsuanhysxVE8ekE2CI8qn2ndkbjAAy5h14fi2adQYgs23N3DY93N/ lvobBnfJXoFd0wx915AHSPF1PBAmwTn80E35ppXXW9vwlI6EhDOA28angJyOL+t+trc21 k+KoaO9RKQIIXOFmsPFCrEu0pXibb0ij7FeIHOV1ar7nyTeLiKgybCHNmTfZCO8cvvclg UzLdNXECIOy2F/O4UUTL7vMcremIdOrxzxIszIqPqJZhgqjFFyh3kAuS7NVkU2qY0bjHw pePUv+n75Q3+82PiiQ6CxOLciSuLheevxtrvp2xm0t4E69A2weA20KMPy/2Jx4q0cIQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379500; 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=B7ImSzbF8tPgBKJwJMOzKt+nQ+3fgQbYdKnHqLEqwg8=; b=s/bjYmuTQjp9TP1Mc3OhdEY55D/liDnofAJt5lqK8ro/yFDnB99s9B0g07gm41fNl1H9 RsbLILZXf2ATCgHsO43EkNn0qNfMtG/n3q9sjvS5XhbYF6iJjXNg+UjGJt+G+u4knWYn2 bbyGG1800K6UVX1nR5Gh27GuzONJKLHUQe3xvbN8SggfyoMJQFxEjSfr8t+P62Syc2VOf OgrWMDTt2qBglaTHTrkYuQpMmVDuDUzT9BtFf+IIYCZPcc8gW0E+R6MKBOHLHVYeyZSjG gUzRuMt8NZLrLUW/VyK0HWX4sLyyEGI0mOzYbfRV6nO0AQt/ofYXULIDW64sd8gYszw== 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=be4DNalK; 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 04C34606A32C; Fri, 4 Dec 2026 10:18:20 +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=be4DNalK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7753B1F0092C; Fri, 4 Dec 2026 10:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379499; bh=B7ImSzbF8tPgBKJwJMOzKt+nQ+3fgQbYdKnHqLEqwg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=be4DNalKKMk896PI4RBxgoEBDebNP85bQvGZ4D7dvbk3yBowwutBsPpcPR/jqDXME hYS3W7NwvE8w6iRALZn2jxeST2hB62PvmRR+Tw0mw3ZUm+wbS3BBKz8bxtJRTWmD0S 5tkRYLRpcCoGe4zaYlyVLJl8r0AFhZPUmFzPzFcw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cheng Yongkang , Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0019/1167] io_uring/timeout: dont rearm a multishot timeout on cancel Date: Fri, 4 Dec 2026 18:50:46 +0900 Message-ID: <20261204100702.545695735@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cheng Yongkang Commit 97d4a585db2b91d855f957be0a9f126068c5be93 upstream. io_timeout_complete() does not check tw.cancel. When it runs from io_cancel_local_task_work(), a multishot timeout that has not reached its count still posts an IORING_CQE_F_MORE completion and rearms its timer. With a zero interval the timer expires again right away and queues new task work, so the drain keeps running it until posting a CQE fails. Normally the CQ fills up quickly and the request then completes. But if userspace moves the CQ head far ahead of the tail, for example to cq.tail + 0x7fffffff, posting keeps succeeding and ring teardown is delayed for a long time. Don't post another CQE or rearm the timer when tw.cancel is set, so the request completes through io_req_task_complete(), like the poll and linked timeout task work does when cancelled. Fixes: ea97f6c8558e ("io_uring: add support for multishot timeouts") Signed-off-by: Cheng Yongkang Link: https://patch.msgid.link/20261116044519.281756-1-teel4res@gmail.com Signed-off-by: Jens Axboe [axboe: 6.6 has no tw.cancel, use io_should_terminate_tw() like io_req_task_link_timeout() does] Signed-off-by: Sasha Levin --- io_uring/timeout.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/io_uring/timeout.c b/io_uring/timeout.c index df9ef01ebf191..4eec4445fafb8 100644 --- a/io_uring/timeout.c +++ b/io_uring/timeout.c @@ -72,9 +72,11 @@ static void io_timeout_complete(struct io_kiocb *req, struct io_tw_state *ts) struct io_ring_ctx *ctx = req->ctx; if (!io_timeout_finish(timeout, data)) { - bool filled; - filled = io_fill_cqe_req_aux(req, ts->locked, -ETIME, - IORING_CQE_F_MORE); + bool filled = false; + + if (!io_should_terminate_tw(ctx)) + filled = io_fill_cqe_req_aux(req, ts->locked, -ETIME, + IORING_CQE_F_MORE); if (filled) { /* re-arm timer */ spin_lock_irq(&ctx->timeout_lock); -- 2.53.0