Skip to content

Commit 8bbed28

Browse files
axboegregkh
authored andcommitted
io_uring/poll: fix multishot recv missing EOF on wakeup race
[ Upstream commit a68ed2d ] 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.6.y: - In 6.6.y the do-while masks v in the while-condition itself (`atomic_sub_return(v & IO_POLL_REF_MASK, ...) & IO_POLL_REF_MASK`), 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`, to avoid reacting to flag bits. - io_poll_issue takes `ts` (struct io_tw_state *) here. CVE: CVE-2026-23473 Cc: stable@vger.kernel.org # 6.6.y Fixes: dbc2564 ("io_uring: let fast poll support multishot") Reported-by: Francis Brosseau <francis@malagauche.com> Link: axboe/liburing#1549 Signed-off-by: Jens Axboe <axboe@kernel.dk> [backport for linux-6.6.y, verified 2026-05-01] Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d26f8c3 commit 8bbed28

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

io_uring/poll.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,13 @@ static int io_poll_check_events(struct io_kiocb *req, struct io_tw_state *ts)
321321
return IOU_POLL_REMOVE_POLL_USE_RES;
322322
}
323323
} else {
324-
int ret = io_poll_issue(req, ts);
324+
int ret;
325+
326+
/* multiple refs and HUP, ensure we loop once more */
327+
if ((req->cqe.res & (POLLHUP | POLLRDHUP)) &&
328+
(v & IO_POLL_REF_MASK) != 1)
329+
v--;
330+
ret = io_poll_issue(req, ts);
325331
if (ret == IOU_STOP_MULTISHOT)
326332
return IOU_POLL_REMOVE_POLL_USE_RES;
327333
else if (ret == IOU_REQUEUE)

0 commit comments

Comments
 (0)