Skip to content

Commit

Permalink
io_uring: ensure symmetry in handling iter types in loop_rw_iter()
Browse files Browse the repository at this point in the history
[upstream commit 16c8d2d]

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]>
  • Loading branch information
axboe authored and dinguyen702 committed Oct 11, 2021
1 parent ba770a5 commit 1a43ac1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -3203,12 +3203,15 @@ static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter)
ret = nr;
break;
}
if (!iov_iter_is_bvec(iter)) {
iov_iter_advance(iter, nr);
} else {
req->rw.len -= nr;
req->rw.addr += nr;
}
ret += nr;
if (nr != iovec.iov_len)
break;
req->rw.len -= nr;
req->rw.addr += nr;
iov_iter_advance(iter, nr);
}

return ret;
Expand Down

0 comments on commit 1a43ac1

Please sign in to comment.