Skip to content

Commit 9a709b7

Browse files
committed
io_uring/net: mark iov as dynamically allocated even for single segments
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 <[email protected]>
1 parent 7cac633 commit 9a709b7

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
@@ -1077,6 +1077,12 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
10771077
if (unlikely(ret < 0))
10781078
return ret;
10791079

1080+
if (arg.iovs != &kmsg->fast_iov && arg.iovs != kmsg->vec.iovec) {
1081+
kmsg->vec.nr = ret;
1082+
kmsg->vec.iovec = arg.iovs;
1083+
req->flags |= REQ_F_NEED_CLEANUP;
1084+
}
1085+
10801086
/* special case 1 vec, can be a fast path */
10811087
if (ret == 1) {
10821088
sr->buf = arg.iovs[0].iov_base;
@@ -1085,11 +1091,6 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
10851091
}
10861092
iov_iter_init(&kmsg->msg.msg_iter, ITER_DEST, arg.iovs, ret,
10871093
arg.out_len);
1088-
if (arg.iovs != &kmsg->fast_iov && arg.iovs != kmsg->vec.iovec) {
1089-
kmsg->vec.nr = ret;
1090-
kmsg->vec.iovec = arg.iovs;
1091-
req->flags |= REQ_F_NEED_CLEANUP;
1092-
}
10931094
} else {
10941095
void __user *buf;
10951096

0 commit comments

Comments
 (0)