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 v10 02/13] iov_iter: add iterator type for dmabuf maps
Date: Tue, 13 Oct 2026 21:13:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-170523@kernel.org> (raw)
In-Reply-To: <20b8e9c900c7656e43e039a0d97213a2a781ba4f.1791924581.git.asml.silence@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] iov_iter: iterate_and_advance_kernel() silently discards ITER_DMABUF_MAP data
- [High] iov_iter: dmabuf absolute offset truncation and revert bounds bypass
--
commit 190aa53efd62f0f61a9121fb6b0b02899d01272d
Author: Pavel Begunkov <asml.silence@gmail.com>
iov_iter: add iterator type for dmabuf maps
Introduce a new iterator type for dmabuf maps. The map in an opaque
object with internals and format specific to the subsystem / driver, and
only it can use that subsystem / driver for issuing IO. The task of the
middle layers is to pass the map / iterator further down, maybe doing
basic splitting and length checking.
> diff --git a/include/linux/iov_iter.h b/include/linux/iov_iter.h
> index f9a17fbbd3980..2f91884d733bf 100644
> --- a/include/linux/iov_iter.h
> +++ b/include/linux/iov_iter.h
> @@ -310,6 +310,8 @@ size_t iterate_and_advance2(struct iov_iter *iter, size_t len, void *priv,
> return iterate_folioq(iter, len, priv, priv2, step);
> if (iov_iter_is_xarray(iter))
> return iterate_xarray(iter, len, priv, priv2, step);
> + if (WARN_ON_ONCE(iov_iter_is_dmabuf_map(iter)))
> + return 0;
> return iterate_discard(iter, len, priv, priv2, step);
> }
[Severity: High]
This patch explicitly rejects ITER_DMABUF_MAP in iterate_and_advance2(), but
does iterate_and_advance_kernel() also need this check?
If an ITER_DMABUF_MAP iterator is passed to iterate_and_advance_kernel(), it
looks like execution will fall through directly to iterate_discard(), which
silently subtracts the requested length from iter->count and returns the
length.
Could this cause internal kernel components to silently bypass data processing
instead of failing loudly?
[ ... ]
> 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
[ ... ]
> @@ -631,7 +632,8 @@ void iov_iter_revert(struct iov_iter *i, size_t unroll)
> return;
> }
> unroll -= i->iov_offset;
> - if (iov_iter_is_xarray(i) || iter_is_ubuf(i)) {
> + if (iov_iter_is_xarray(i) || iter_is_ubuf(i) ||
> + iov_iter_is_dmabuf_map(i)) {
> BUG(); /* We should never go beyond the start of the specified
> * range since we might then be straying into pages that
> * aren't pinned.
[Severity: High]
Does setting iov_offset to the absolute file offset in iov_iter_dmabuf_map()
break the bounds check in iov_iter_revert() prior to this BUG() guard?
In iov_iter_revert(), the check is:
if (unroll <= i->iov_offset) {
i->iov_offset -= unroll;
return;
}
If iov_offset contains an absolute offset rather than relative progress (0),
does this evaluate the relative unroll amount against the absolute offset,
allowing the iterator to rewind completely out of bounds without hitting
the BUG() safety check?
[ ... ]
> @@ -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: High]
Since iov_offset is defined as a size_t, does assigning the loff_t off
truncate the offset on 32-bit architectures?
Additionally, when this iterator is mapped into a bio in subsequent patches,
iter->iov_offset is copied into bio->bi_iter.bi_offset (an unsigned int).
Does this cause truncation on 64-bit architectures as well?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791924581.git.asml.silence@gmail.com?part=2
next prev parent reply other threads:[~2026-10-13 21:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 20:54 [PATCH v10 00/13] Add dmabuf read/write via io_uring Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 01/13] dma-buf: introduce initial file I/O infrastructure Pavel Begunkov
2026-10-13 21:06 ` sashiko-bot
2026-10-13 20:54 ` [PATCH v10 02/13] iov_iter: add iterator type for dmabuf maps Pavel Begunkov
2026-10-13 21:13 ` sashiko-bot [this message]
2026-10-13 20:54 ` [PATCH v10 03/13] block: always adjust bi_offset on bio_advance_iter Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 04/13] block: introduce dma map backed bio type Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 05/13] block: add dma-buf support for raw bdev Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 06/13] nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 07/13] nvme-pci: implement dma-buf backed requests Pavel Begunkov
2026-10-13 21:23 ` sashiko-bot
2026-10-13 20:54 ` [PATCH v10 08/13] nvme-pci: add SGL support for the dmabuf path Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 09/13] io_uring/rsrc: introduce buf registration structure Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 10/13] io_uring/rsrc: extend buffer update Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 11/13] io_uring/rsrc: add uncloneable regbuf flag Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 12/13] io_uring/rsrc: add regbuf import flags Pavel Begunkov
2026-10-13 20:54 ` [PATCH v10 13/13] io_uring/rsrc: add dmabuf backed registered buffers Pavel Begunkov
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=sashiko-outbox-170523@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.