Skip to content

Commit c8d152b

Browse files
axboegregkh
authored andcommitted
io_uring/net: mark iov as dynamically allocated even for single segments
Commit 9a709b7 upstream. A bigger array of vecs could've been allocated, but io_ring_buffers_peek() still decided to cap the mapped range depending on how much data was available. Hence don't rely on the segment count to know if the request should be marked as needing cleanup, always check upfront if the iov array is different than the fast_iov array. Fixes: 26ec15e ("io_uring/kbuf: don't truncate end buffer for multiple buffer peeks") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b8be3ae commit c8d152b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

io_uring/net.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,12 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
11181118
if (unlikely(ret < 0))
11191119
return ret;
11201120

1121+
if (arg.iovs != &kmsg->fast_iov && arg.iovs != kmsg->free_iov) {
1122+
kmsg->free_iov_nr = ret;
1123+
kmsg->free_iov = arg.iovs;
1124+
req->flags |= REQ_F_NEED_CLEANUP;
1125+
}
1126+
11211127
/* special case 1 vec, can be a fast path */
11221128
if (ret == 1) {
11231129
sr->buf = arg.iovs[0].iov_base;
@@ -1126,11 +1132,6 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
11261132
}
11271133
iov_iter_init(&kmsg->msg.msg_iter, ITER_DEST, arg.iovs, ret,
11281134
arg.out_len);
1129-
if (arg.iovs != &kmsg->fast_iov && arg.iovs != kmsg->free_iov) {
1130-
kmsg->free_iov_nr = ret;
1131-
kmsg->free_iov = arg.iovs;
1132-
req->flags |= REQ_F_NEED_CLEANUP;
1133-
}
11341135
} else {
11351136
void __user *buf;
11361137

0 commit comments

Comments
 (0)