All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pavel Begunkov" <asml.silence@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v6 02/13] iov_iter: add iterator type for dmabuf maps
Date: Mon, 21 Sep 2026 13:53:37 +0000	[thread overview]
Message-ID: <20260921135338.241751F000FF@smtp.kernel.org> (raw)
In-Reply-To: <6b78003332b57ec3a4552d7393464636793aff76.1789997898.git.asml.silence@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] iov_iter: silent fallback to iterate_discard() for dmabuf maps
- [Medium] iov_iter: bounds check bypass in iov_iter_revert() for dmabuf maps
--

commit 8e47b333dea94c1451175bac8e284adfbbf175cc
Author: Pavel Begunkov <asml.silence@gmail.com>
Subject: iov_iter: add iterator type for dmabuf maps

Introduce a new ITER_DMABUF_MAP iterator type for dmabuf maps. The patch 
adds the new iterator type, updates struct iov_iter to hold dmabuf maps, 
and wires up basic iterator operations like advance, revert, and alignment.

> diff --git a/include/linux/uio.h b/include/linux/uio.h
> index fe2e985d74d24..638c1116e912e 100644
> --- a/include/linux/uio.h
> +++ b/include/linux/uio.h
[ ... ]
> @@ -29,6 +30,7 @@ enum iter_type {
>  	ITER_FOLIOQ,
>  	ITER_XARRAY,
>  	ITER_DISCARD,
> +	ITER_DMABUF_MAP,
>  };

[Severity: Medium]
With the addition of ITER_DMABUF_MAP here, do iterate_and_advance2() and 
iterate_and_advance_kernel() in include/linux/iov_iter.h also need to be 
updated?

It appears they currently lack a type check for ITER_DMABUF_MAP, which 
might cause operations like copy_to_iter() or copy_from_iter() to silently 
fall through to iterate_discard(). If any middle layer attempts to read or 
write using this iterator type, the operation would drop data and return 
success without reporting an error.

[ ... ]
> diff --git a/lib/iov_iter.c b/lib/iov_iter.c
> index 2072c04e99d05..6831a5d9396e1 100644
> --- a/lib/iov_iter.c
> +++ b/lib/iov_iter.c
[ ... ]
> @@ -775,6 +777,20 @@ void iov_iter_xarray(struct iov_iter *i, unsigned int direction,
>  }
>  EXPORT_SYMBOL(iov_iter_xarray);
>  
> +void iov_iter_dmabuf_map(struct iov_iter *i, unsigned int direction,
> +			 struct dma_buf_io_map *map,
> +			 loff_t off, size_t count)
> +{
> +	WARN_ON(direction & ~(READ | WRITE));
> +	*i = (struct iov_iter){
> +		.iter_type = ITER_DMABUF_MAP,
> +		.data_source = direction,
> +		.dmabuf_map = map,
> +		.count = count,
> +		.iov_offset = off,
> +	};
> +}

[Severity: Medium]
Since iov_offset is initialized here to the absolute starting offset (off) 
rather than a relative zero, does this cause an issue with the tracking 
logic in iov_iter_revert()?

In iov_iter_revert(), the unroll size is checked against i->iov_offset 
like this:

	if (unroll <= i->iov_offset) {
		i->iov_offset -= unroll;
		return;
	}

Because iov_offset starts at the absolute offset rather than 0, couldn't a 
caller successfully revert an ITER_DMABUF_MAP iterator beyond its initial 
starting offset? This would bypass the BUG() safety net intended to catch 
invalid unrolls, potentially leading to an out-of-bounds DMA access if the 
reverted iterator is used again.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789997898.git.asml.silence@gmail.com?part=2

  reply	other threads:[~2026-09-21 13:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 13:38 [PATCH v6 00/13] Add dmabuf read/write via io_uring Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 01/13] dma-buf: introduce initial file I/O infrastructure Pavel Begunkov
2026-09-21 13:53   ` sashiko-bot
2026-09-22  9:08     ` Pavel Begunkov
2026-09-30  6:54       ` Matthew Brost
2026-09-30 10:03         ` Pavel Begunkov
2026-09-30  3:00   ` Matthew Brost
2026-09-30 10:08     ` Pavel Begunkov
2026-09-30 12:48       ` Pavel Begunkov
2026-09-30 19:43         ` Matthew Brost
2026-10-05 11:49           ` Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 02/13] iov_iter: add iterator type for dmabuf maps Pavel Begunkov
2026-09-21 13:53   ` sashiko-bot [this message]
2026-09-22  9:15     ` Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 03/13] block: always adjust bi_offset on bio_advance_iter Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 04/13] block: introduce dma map backed bio type Pavel Begunkov
2026-09-22 13:16   ` Christoph Hellwig
2026-09-22 13:54     ` Pavel Begunkov
2026-09-23  4:51       ` Christoph Hellwig
2026-09-21 13:38 ` [PATCH v6 05/13] block: add dma-buf support for raw bdev Pavel Begunkov
2026-09-21 13:50   ` sashiko-bot
2026-09-21 13:38 ` [PATCH v6 06/13] nvme-pci: implement dma-buf backed requests Pavel Begunkov
2026-09-21 13:58   ` sashiko-bot
2026-09-22 13:20   ` Christoph Hellwig
2026-09-22 13:37     ` Pavel Begunkov
2026-09-23  4:55       ` Christoph Hellwig
2026-09-24 15:53         ` Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 07/13] nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 08/13] nvme-pci: add SGL support for the dmabuf path Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 09/13] io_uring/rsrc: introduce buf registration structure Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 10/13] io_uring/rsrc: extend buffer update Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 11/13] io_uring/rsrc: add uncloneable regbuf flag Pavel Begunkov
2026-09-21 13:53   ` sashiko-bot
2026-09-21 13:38 ` [PATCH v6 12/13] io_uring/rsrc: add regbuf import flags Pavel Begunkov
2026-09-21 13:38 ` [PATCH v6 13/13] io_uring/rsrc: add dmabuf backed registered buffers Pavel Begunkov
2026-09-21 13:54   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260921135338.241751F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=asml.silence@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.