]> git.hungrycats.org Git - linux/commit
iov_iter: Fix iov_iter_extract_pages() with zero-sized entries
authorDavid Howells <dhowells@redhat.com>
Fri, 8 Sep 2023 16:03:20 +0000 (17:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:48:42 +0000 (09:48 +0200)
commitb15d3cbd29412f8db94d9b424ec17c84ccd71203
treec6134eaa62282e8bfa173ed75c9259c38764fea6
parent5db357b14d4032c2ef07ee8436eb42973dc17b25
iov_iter: Fix iov_iter_extract_pages() with zero-sized entries

commit f741bd7178c95abd7aeac5a9d933ee542f9a5509 upstream.

iov_iter_extract_pages() doesn't correctly handle skipping over initial
zero-length entries in ITER_KVEC and ITER_BVEC-type iterators.

The problem is that it accidentally reduces maxsize to 0 when it
skipping and thus runs to the end of the array and returns 0.

Fix this by sticking the calculated size-to-copy in a new variable
rather than back in maxsize.

Fixes: 7d58fe731028 ("iov_iter: Add a function to extract a page list from an iterator")
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: David Hildenbrand <david@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/iov_iter.c