From: Kai Aizen <kai.aizen.dev@gmail.com>
To: stable@vger.kernel.org
Cc: gregkh@linuxfoundation.org, axboe@kernel.dk, io-uring@vger.kernel.org
Subject: [PATCH 6.1.y] io_uring/poll: fix multishot recv missing EOF on wakeup race
Date: Sat, 2 May 2026 01:51:56 +0300 [thread overview]
Message-ID: <20260501225250.90152-3-kai.aizen.dev@gmail.com> (raw)
In-Reply-To: <20260501225250.90152-1-kai.aizen.dev@gmail.com>
From: Jens Axboe <axboe@kernel.dk>
[ Upstream commit a68ed2df72131447d131531a08fe4dfcf4fa4653 ]
When a socket send and shutdown() happen back-to-back, both fire
wake-ups before the receiver's task_work has a chance to run. The first
wake gets poll ownership (poll_refs=1), and the second bumps it to 2.
When io_poll_check_events() runs, it calls io_poll_issue() which does a
recv that reads the data and returns IOU_RETRY. The loop then drains all
accumulated refs (atomic_sub_return(2) -> 0) and exits, even though only
the first event was consumed. Since the shutdown is a persistent state
change, no further wakeups will happen, and the multishot recv can hang
forever.
Check specifically for HUP in the poll loop, and ensure that another
loop is done to check for status if more than a single poll activation
is pending. This ensures we don't lose the shutdown event.
Backport notes for linux-6.1.y:
- In 6.1.y the do-while masks v in the while-condition itself, so
v can carry IO_POLL_RETRY_FLAG/IO_POLL_CANCEL_FLAG bits when we
reach the multishot branch. The HUP check therefore compares
`(v & IO_POLL_REF_MASK) != 1` rather than the upstream `v != 1`.
- io_poll_issue takes `bool *locked` here (renamed to `ts` in 6.6+).
- 6.1.y has no IOU_REQUEUE return path; only IOU_STOP_MULTISHOT.
CVE: CVE-2026-23473
Cc: stable@vger.kernel.org # 6.1.y
Fixes: dbc2564cfe0f ("io_uring: let fast poll support multishot")
Reported-by: Francis Brosseau <francis@malagauche.com>
Link: https://github.com/axboe/liburing/issues/1549
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[backport for linux-6.1.y, verified 2026-05-01]
---
io_uring/poll.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/io_uring/poll.c b/io_uring/poll.c
--- a/io_uring/poll.c
+++ b/io_uring/poll.c
@@ -303,7 +303,13 @@ static int io_poll_check_events(struct io_kiocb *req, bool *locked)
return IOU_POLL_REMOVE_POLL_USE_RES;
}
} else {
- int ret = io_poll_issue(req, locked);
+ int ret;
+
+ /* multiple refs and HUP, ensure we loop once more */
+ if ((req->cqe.res & (POLLHUP | POLLRDHUP)) &&
+ (v & IO_POLL_REF_MASK) != 1)
+ v--;
+ ret = io_poll_issue(req, locked);
io_kbuf_recycle(req, 0);
if (ret == IOU_STOP_MULTISHOT)
--
2.43.0
next prev parent reply other threads:[~2026-05-01 22:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 22:51 [PATCH 6.12.y] io_uring/poll: fix multishot recv missing EOF on wakeup race Kai Aizen
2026-05-01 22:51 ` [PATCH 6.6.y] " Kai Aizen
2026-05-01 22:51 ` Kai Aizen [this message]
2026-05-01 22:51 ` [PATCH stable] io_uring/poll: ensure EPOLL_ONESHOT is propagated for EPOLL_URING_WAKE Kai Aizen
2026-05-01 22:56 ` Jens Axboe
2026-05-01 22:55 ` [PATCH 6.12.y] io_uring/poll: fix multishot recv missing EOF on wakeup race Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260501225250.90152-3-kai.aizen.dev@gmail.com \
--to=kai.aizen.dev@gmail.com \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=io-uring@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox