Skip to content

Commit 725fcba

Browse files
axboegregkh
authored andcommitted
io_uring/net: only consider msg_inq if larger than 1
Commit 2c7f023 upstream. Currently retry and general validity of msg_inq is gated on it being larger than zero, but it's entirely possible for this to be slightly inaccurate. In particular, if FIN is received, it'll return 1. Just use larger than 1 as the check. This covers both the FIN case, and at the same time, it doesn't make much sense to retry a recv immediately if there's even just a single 1 byte of valid data in the socket. Leave the SOCK_NONEMPTY flagging when larger than 0 still, as an app may use that for the final receive. Cc: [email protected] Reported-by: Christian Mazakas <[email protected]> Fixes: 7c71a0a ("io_uring/net: improve recv bundles") Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0c07f2b commit 725fcba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

io_uring/net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
865865
* If more is available AND it was a full transfer, retry and
866866
* append to this one
867867
*/
868-
if (!sr->retry && kmsg->msg.msg_inq > 0 && this_ret > 0 &&
868+
if (!sr->retry && kmsg->msg.msg_inq > 1 && this_ret > 0 &&
869869
!iov_iter_count(&kmsg->msg.msg_iter)) {
870870
req->cqe.flags = cflags & ~CQE_F_MASK;
871871
sr->len = kmsg->msg.msg_inq;
@@ -1111,7 +1111,7 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
11111111
arg.mode |= KBUF_MODE_FREE;
11121112
}
11131113

1114-
if (kmsg->msg.msg_inq > 0)
1114+
if (kmsg->msg.msg_inq > 1)
11151115
arg.max_len = min_not_zero(sr->len, kmsg->msg.msg_inq);
11161116

11171117
ret = io_buffers_peek(req, &arg);

0 commit comments

Comments
 (0)