On Thu, Oct 31, 2024 at 07:02:24PM +0800, Ming Lei wrote: > Initialize bi.bi_idx as 0 before iterating over bvec, otherwise > garbage data can be used as ->bi_idx. > > Cc: Christoph Hellwig <hch@xxxxxx> > Reported-and-tested-by: Klara Modin <klarasmodin@xxxxxxxxx> > Fixes: e4e535bff2bc ("iov_iter: don't require contiguous pages in iov_iter_extract_bvec_pages") > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > --- > lib/iov_iter.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/iov_iter.c b/lib/iov_iter.c > index 9fc06f5fb748..c761f6db3cb4 100644 > --- a/lib/iov_iter.c > +++ b/lib/iov_iter.c > @@ -1699,6 +1699,7 @@ static ssize_t iov_iter_extract_bvec_pages(struct iov_iter *i, > i->bvec++; > skip = 0; > } > + bi.bi_idx = 0; Looks good, but the more future proof variant would be to initialize bi to zero at declaration time: struct bvec_iter bi = { }; Either way: Reviewed-by: Christoph Hellwig <hch@xxxxxx>