Skip to content

Commit f28044a

Browse files
isilencegregkh
authored andcommitted
io_uring/poll: fix POLLERR handling
commit c7cafd5 upstream. 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 134ec1e commit f28044a

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
@@ -1735,9 +1735,11 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
17351735
int ret;
17361736
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
17371737

1738-
if (unlikely(req->flags & REQ_F_FAIL)) {
1739-
ret = -ECONNRESET;
1740-
goto out;
1738+
if (connect->in_progress) {
1739+
struct poll_table_struct pt = { ._key = EPOLLERR };
1740+
1741+
if (vfs_poll(req->file, &pt) & EPOLLERR)
1742+
goto get_sock_err;
17411743
}
17421744

17431745
file_flags = force_nonblock ? O_NONBLOCK : 0;
@@ -1762,8 +1764,10 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
17621764
* which means the previous result is good. For both of these,
17631765
* grab the sock_error() and use that for the completion.
17641766
*/
1765-
if (ret == -EBADFD || ret == -EISCONN)
1767+
if (ret == -EBADFD || ret == -EISCONN) {
1768+
get_sock_err:
17661769
ret = sock_error(sock_from_file(req->file)->sk);
1770+
}
17671771
}
17681772
if (ret == -ERESTARTSYS)
17691773
ret = -EINTR;

io_uring/poll.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ static int io_poll_check_events(struct io_kiocb *req, struct io_tw_state *ts)
315315
return IOU_POLL_REISSUE;
316316
}
317317
}
318-
if (unlikely(req->cqe.res & EPOLLERR))
319-
req_set_fail(req);
320318
if (req->apoll_events & EPOLLONESHOT)
321319
return IOU_POLL_DONE;
322320

0 commit comments

Comments
 (0)