Skip to content

Commit a37ee9e

Browse files
committed
io_uring/net: fix multishot accept overflow handling
If we hit CQ ring overflow when attempting to post a multishot accept completion, we don't properly save the result or return code. This results in losing the accepted fd value. Instead, we return the result from the poll operation that triggered the accept retry. This is generally POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND which is 0xc3, or 195, which looks like a valid file descriptor, but it really has no connection to that. Handle this like we do for other multishot completions - assign the result, and return IOU_STOP_MULTISHOT to cancel any further completions from this request when overflow is hit. This preserves the result, as we should, and tells the application that the request needs to be re-armed. Cc: stable@vger.kernel.org Fixes: 515e269 ("io_uring: revert "io_uring fix multishot accept ordering"") Link: axboe/liburing#1062 Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 72bd802 commit a37ee9e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

io_uring/net.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
13721372
* has already been done
13731373
*/
13741374
if (issue_flags & IO_URING_F_MULTISHOT)
1375-
ret = IOU_ISSUE_SKIP_COMPLETE;
1375+
return IOU_ISSUE_SKIP_COMPLETE;
13761376
return ret;
13771377
}
13781378
if (ret == -ERESTARTSYS)
@@ -1397,7 +1397,8 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
13971397
ret, IORING_CQE_F_MORE))
13981398
goto retry;
13991399

1400-
return -ECANCELED;
1400+
io_req_set_res(req, ret, 0);
1401+
return IOU_STOP_MULTISHOT;
14011402
}
14021403

14031404
int io_socket_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)

0 commit comments

Comments
 (0)