From: sashiko-bot@kernel.org
To: "Pavel Begunkov" <asml.silence@gmail.com>
Cc: media-ci@linuxtv.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7 02/13] iov_iter: add iterator type for dmabuf maps
Date: Mon, 28 Sep 2026 13:49:51 +0000 [thread overview]
Message-ID: <20260928134952.74FB61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <74a9d65f5c4f9acce5f57ad5921a9fadc6eda712.1790602223.git.asml.silence@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] iov_iter: silent data discard for ITER_DMABUF_MAP in iterate_and_advance_kernel
- [Medium] iov_iter: iov_iter_revert() fails to prevent ITER_DMABUF_MAP from reverting past start
--
commit 592c6072da9af2f29c973e9a7808406da6345041
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.
> 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 safely rejects ITER_DMABUF_MAP by returning 0, but is there a missing
guard in iterate_and_advance_kernel() which is defined later in this file?
If a kernel subsystem uses iterate_and_advance_kernel() on an
ITER_DMABUF_MAP, it will unconditionally fall through to iterate_discard():
if (iov_iter_is_xarray(iter))
return iterate_xarray(iter, len, priv, priv2, step);
return iterate_discard(iter, len, priv, priv2, step);
iterate_discard() decrements count and returns the requested len, falsely
indicating that the data was successfully processed without actually calling
the step function.
Can this lead to silent data discard or corruption (such as hashing missing
data) without any warning or error propagation?
> 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: Medium]
Does this safely prevent ITER_DMABUF_MAP from reverting past its start?
iov_iter_dmabuf_map() initializes i->iov_offset to the absolute offset (off)
rather than 0.
Earlier in iov_iter_revert(), the boundary check compares the revert amount
against this absolute offset rather than the amount advanced:
if (unroll <= i->iov_offset) {
i->iov_offset -= unroll;
return;
}
Because of this early return, the revert can rewind the iterator by up to
off + advanced bytes without triggering the BUG() safeguard shown in this
hunk.
Can this allow a caller to silently rewind the iterator to an out-of-bounds
offset before the mapped range?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790602223.git.asml.silence@gmail.com?part=2
next prev parent reply other threads:[~2026-09-28 13:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 13:32 [PATCH v7 00/13] Add dmabuf read/write via io_uring Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 01/13] dma-buf: introduce initial file I/O infrastructure Pavel Begunkov
2026-09-28 13:46 ` sashiko-bot
2026-09-29 16:12 ` Christophe JAILLET
2026-09-28 13:32 ` [PATCH v7 02/13] iov_iter: add iterator type for dmabuf maps Pavel Begunkov
2026-09-28 13:49 ` sashiko-bot [this message]
[not found] ` <20261005091008.GA10727@lst.de>
2026-10-05 11:44 ` Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 03/13] block: always adjust bi_offset on bio_advance_iter Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 04/13] block: introduce dma map backed bio type Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 05/13] block: add dma-buf support for raw bdev Pavel Begunkov
2026-09-28 13:46 ` sashiko-bot
[not found] ` <20261005091111.GB10727@lst.de>
2026-10-05 11:43 ` Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 06/13] nvme-pci: implement dma-buf backed requests Pavel Begunkov
2026-09-28 14:02 ` sashiko-bot
2026-09-28 14:41 ` Pavel Begunkov
2026-09-29 15:45 ` Christophe JAILLET
2026-09-30 10:09 ` Pavel Begunkov
[not found] ` <20261005091554.GD10727@lst.de>
2026-10-05 11:45 ` Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 07/13] nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 08/13] nvme-pci: add SGL support for the dmabuf path Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 09/13] io_uring/rsrc: introduce buf registration structure Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 10/13] io_uring/rsrc: extend buffer update Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 11/13] io_uring/rsrc: add uncloneable regbuf flag Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 12/13] io_uring/rsrc: add regbuf import flags Pavel Begunkov
2026-09-28 13:32 ` [PATCH v7 13/13] io_uring/rsrc: add dmabuf backed registered buffers Pavel Begunkov
2026-09-28 14:03 ` 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=20260928134952.74FB61F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox