[BUG] io_uring/timeout: multishot timeout rearms during cancel drain
From: Cheng Yongkang
Date: Sun Nov 15 2026 - 11:36:02 EST
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