Skip to content

Commit 8c8492c

Browse files
committed
io_uring/net: don't retry connect operation on EPOLLERR
If a socket is shutdown before the connection completes, POLLERR is set in the poll mask. However, connect ignores this as it doesn't know, and attempts the connection again. This may lead to a bogus -ETIMEDOUT result, where it should have noticed the POLLERR and just returned -ECONNRESET instead. Have the poll logic check for whether or not POLLERR is set in the mask, and if so, mark the request as failed. Then connect can appropriately fail the request rather than retry it. Reported-by: Sergey Galas <ssgalas@cloud.ru> Cc: stable@vger.kernel.org Link: axboe/liburing#1335 Fixes: 3fb1bd6 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent d1fdab8 commit 8c8492c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

io_uring/net.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,11 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
17101710
int ret;
17111711
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
17121712

1713+
if (unlikely(req->flags & REQ_F_FAIL)) {
1714+
ret = -ECONNRESET;
1715+
goto out;
1716+
}
1717+
17131718
file_flags = force_nonblock ? O_NONBLOCK : 0;
17141719

17151720
ret = __sys_connect_file(req->file, &io->addr, connect->addr_len,

io_uring/poll.c

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

0 commit comments

Comments
 (0)