io_uring: revert consumed iov_iter bytes on error
authorJens Axboe <axboe@kernel.dk>
Mon, 24 Aug 2020 17:45:26 +0000 (11:45 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 25 Aug 2020 13:28:43 +0000 (07:28 -0600)
Some consumers of the iov_iter will return an error, but still have
bytes consumed in the iterator. This is an issue for -EAGAIN, since we
rely on a sane iov_iter state across retries.

Fix this by ensuring that we revert consumed bytes, if any, if the file
operations have consumed any bytes from iterator. This is similar to what
generic_file_read_iter() does, and is always safe as we have the previous
bytes count handy already.

Fixes: ff6165b2d7f6 ("io_uring: retain iov_iter state over io_read/io_write calls")
Reported-by: Dmitry Shulyak <yashulyak@gmail.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

No differences found