Skip to content

Commit 16c8d2d

Browse files
committed
io_uring: ensure symmetry in handling iter types in loop_rw_iter()
When setting up the next segment, we check what type the iter is and handle it accordingly. However, when incrementing and processed amount we do not, and both iter advance and addr/len are adjusted, regardless of type. Split the increment side just like we do on the setup side. Fixes: 4017eb9 ("io_uring: make loop_rw_iter() use original user supplied pointers") Cc: [email protected] Reported-by: Valentina Palmiotti <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6880fa6 commit 16c8d2d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/io_uring.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,12 +3263,15 @@ static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter)
32633263
ret = nr;
32643264
break;
32653265
}
3266+
if (!iov_iter_is_bvec(iter)) {
3267+
iov_iter_advance(iter, nr);
3268+
} else {
3269+
req->rw.len -= nr;
3270+
req->rw.addr += nr;
3271+
}
32663272
ret += nr;
32673273
if (nr != iovec.iov_len)
32683274
break;
3269-
req->rw.len -= nr;
3270-
req->rw.addr += nr;
3271-
iov_iter_advance(iter, nr);
32723275
}
32733276

32743277
return ret;

0 commit comments

Comments
 (0)