Skip to content

Commit 5af6d82

Browse files
author
Ming Lei
committed
io_uring/poll: fix POLLERR handling
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit c7cafd5 Author: Pavel Begunkov <asml.silence@gmail.com> Date: Wed Jul 16 17:20:17 2025 +0100 io_uring/poll: fix POLLERR handling 8c8492c ("io_uring/net: don't retry connect operation on EPOLLERR") is a little dirty hack that 1) wrongfully assumes that POLLERR equals to a failed request, which breaks all POLLERR users, e.g. all error queue recv interfaces. 2) deviates the connection request behaviour from connect(2), and 3) racy and solved at a wrong level. Nothing can be done with 2) now, and 3) is beyond the scope of the patch. At least solve 1) by moving the hack out of generic poll handling into io_connect(). Cc: stable@vger.kernel.org Fixes: 8c8492c ("io_uring/net: don't retry connect operation on EPOLLERR") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/3dc89036388d602ebd84c28e5042e457bdfc952b.1752682444.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent c09c0b4 commit 5af6d82

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

io_uring/net.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,9 +1665,11 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
16651665
int ret;
16661666
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
16671667

1668-
if (unlikely(req->flags & REQ_F_FAIL)) {
1669-
ret = -ECONNRESET;
1670-
goto out;
1668+
if (connect->in_progress) {
1669+
struct poll_table_struct pt = { ._key = EPOLLERR };
1670+
1671+
if (vfs_poll(req->file, &pt) & EPOLLERR)
1672+
goto get_sock_err;
16711673
}
16721674

16731675
file_flags = force_nonblock ? O_NONBLOCK : 0;
@@ -1692,8 +1694,10 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
16921694
* which means the previous result is good. For both of these,
16931695
* grab the sock_error() and use that for the completion.
16941696
*/
1695-
if (ret == -EBADFD || ret == -EISCONN)
1697+
if (ret == -EBADFD || ret == -EISCONN) {
1698+
get_sock_err:
16961699
ret = sock_error(sock_from_file(req->file)->sk);
1700+
}
16971701
}
16981702
if (ret == -ERESTARTSYS)
16991703
ret = -EINTR;

io_uring/poll.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw)
273273
return IOU_POLL_REISSUE;
274274
}
275275
}
276-
if (unlikely(req->cqe.res & EPOLLERR))
277-
req_set_fail(req);
278276
if (req->apoll_events & EPOLLONESHOT)
279277
return IOU_POLL_DONE;
280278

0 commit comments

Comments
 (0)