Re: [PATCH v3] block: Fix start and length check added to iov_iter_extract_bvecs()

From: Christoph Hellwig

Date: Wed Sep 09 2026 - 02:33:36 EST


On Mon, Sep 07, 2026 at 01:21:34PM +0100, David Howells wrote:
> index 6665372ecf71..5e9f9e2c30b1 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
> @@ -1921,15 +1921,29 @@ ssize_t iov_iter_extract_bvecs(struct iov_iter *iter, struct bio_vec *bv,
> unsigned short max_vecs, unsigned mem_align_mask,
> iov_iter_extraction_t extraction_flags)
> {
> - unsigned long start = (unsigned long)iter_iov_addr(iter);
> unsigned short entries_left = max_vecs - *nr_vecs;
> unsigned short nr_pages, i = 0;
> size_t left, offset, len;
> struct page **pages;
> ssize_t size;
>
> - if ((start | iter_iov_len(iter)) & mem_align_mask)
> + /*
> + * DMA engines typically have both memory address and length alignment
> + * requirements, so check these against the alignment mask. For UBUF,
> + * IOVEC and KVEC, only the current segment will be drawn from; for
> + * everything else we might draw from multiple segments, so we need to
> + * check those too.

I have a bit of a hard time understanding what "draw from" means here?
I guess you mean that iov_iter_extract_pages only operates on a single
iov/kvec/bvec but could touch multiple segments for the others?
Maybe try to explain that without introducing new terminology?