lib/iov_iter.c: initialize bi.bi_idx before iterating over bvec

Initialize bi.bi_idx as 0 before iterating over bvec, otherwise
garbage data can be used as ->bi_idx.

Cc: Christoph Hellwig <hch@lst.de>
Reported-and-tested-by: Klara Modin <klarasmodin@gmail.com>
Fixes: e4e535bff2 ("iov_iter: don't require contiguous pages in iov_iter_extract_bvec_pages")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Ming Lei 2024-10-31 19:02:24 +08:00 committed by Jens Axboe
parent 133008e84b
commit 496a51b371

View File

@ -1699,6 +1699,7 @@ static ssize_t iov_iter_extract_bvec_pages(struct iov_iter *i,
i->bvec++;
skip = 0;
}
bi.bi_idx = 0;
bi.bi_size = maxsize + skip;
bi.bi_bvec_done = skip;