mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] io_uring/timeout: multishot timeout rearms during cancel drain
@ 2026-11-15 16:35 Cheng Yongkang
  2026-11-15 16:42 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Cheng Yongkang @ 2026-11-15 16:35 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, linux-kernel

Hi Jens,

I hit a corner case in io_timeout_complete(). It only shows up when
userspace sets the CQ head to a bogus value, so it may not be worth
fixing. I am reporting it in case you want the check.

io_timeout_complete() does not look at tw.cancel, unlike
io_poll_check_events(), io_req_task_submit() and the linked timeout
handler in the same file. During io_cancel_local_task_work(), a
zero-interval multishot timeout still posts a CQE and rearms its
timer, which queues new task work. The drain keeps running it until
CQE posting fails.

Normally the CQ fills up quickly and the request then completes. But
if userspace sets the CQ head to cq.tail + 0x7fffffff, posting keeps
succeeding for about 2^31 CQEs. On v7.3 with DEFER_TASKRUN and 4096
such timeouts, the ring was still not freed 5 seconds after close.

Skipping the rearm when tw.cancel is set fixes it:

  -		if (io_req_post_cqe(req, -ETIME, IORING_CQE_F_MORE)) {
  +		if (!tw.cancel &&
  +		    io_req_post_cqe(req, -ETIME, IORING_CQE_F_MORE)) {

With this change the same test frees the ring in about 300 ms, and
normal multishot timeouts behave as before. The code is unchanged in
next-20261113. I can send a patch if you want one.

Thanks,
Cheng Yongkang

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-15 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 16:35 [BUG] io_uring/timeout: multishot timeout rearms during cancel drain Cheng Yongkang
2026-11-15 16:42 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®