summaryrefslogtreecommitdiff
path: root/io_uring/net.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-07-16 17:20:17 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-24 08:53:12 +0200
commitd48845afa083bb606cb2f81e8bf542e224980620 (patch)
treefeac2575f0aaa4a2b6f0f2b6e4ab149c495a34fb /io_uring/net.c
parentc855b9aa093a4fe2b58b11c2fbbb74144a7535be (diff)
downloadlinux-d48845afa083bb606cb2f81e8bf542e224980620.tar.gz
linux-d48845afa083bb606cb2f81e8bf542e224980620.tar.bz2
linux-d48845afa083bb606cb2f81e8bf542e224980620.zip
io_uring/poll: fix POLLERR handling
commit c7cafd5b81cc07fb402e3068d134c21e60ea688c upstream. 8c8492ca64e7 ("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: 8c8492ca64e79 ("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>
Diffstat (limited to 'io_uring/net.c')
-rw-r--r--io_uring/net.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/io_uring/net.c b/io_uring/net.c
index 4948a67bbac4..e455f051e62e 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1537,9 +1537,11 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
io = &__io;
}
- if (unlikely(req->flags & REQ_F_FAIL)) {
- ret = -ECONNRESET;
- goto out;
+ if (connect->in_progress) {
+ struct poll_table_struct pt = { ._key = EPOLLERR };
+
+ if (vfs_poll(req->file, &pt) & EPOLLERR)
+ goto get_sock_err;
}
file_flags = force_nonblock ? O_NONBLOCK : 0;
@@ -1571,8 +1573,10 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
* which means the previous result is good. For both of these,
* grab the sock_error() and use that for the completion.
*/
- if (ret == -EBADFD || ret == -EISCONN)
+ if (ret == -EBADFD || ret == -EISCONN) {
+get_sock_err:
ret = sock_error(sock_from_file(req->file)->sk);
+ }
}
if (ret == -ERESTARTSYS)
ret = -EINTR;