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 v9 02/13] iov_iter: add iterator type for dmabuf maps
Date: Wed, 07 Oct 2026 01:57:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-162575@kernel.org> (raw)
In-Reply-To: <c6259482b609b9c98c74cedcc2d600774e2ac3a4.1791336930.git.asml.silence@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] lib: iov_iter_dmabuf_map 64-bit offset truncation and revert underflow
--
commit 51412f5d857b723775fa3b8143fbc7dfc3a8a633
Author: Pavel Begunkov <asml.silence@gmail.com>
iov_iter: add iterator type for dmabuf maps
This commit introduces a new iterator type, ITER_DMABUF_MAP, for dmabuf maps.
The map is an opaque object specific to the subsystem or driver, and the
iterator is used by the middle layers to pass the map further down for IO
operations.
> 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
[Severity: High]
Because ITER_DMABUF_MAP sets iov_offset to the absolute file offset in
iov_iter_dmabuf_map(), does this break the safety invariant here?
For iterators validated by this BUG() check (such as ITER_XARRAY and
ITER_UBUF), iov_offset is normally strictly initialized to 0 to track the
relative number of bytes advanced. Since iov_offset starts at the absolute
offset for ITER_DMABUF_MAP, the condition if (unroll <= i->iov_offset) just
above this hunk could evaluate to true even if the caller attempts to unroll
more bytes than were actually advanced, potentially allowing silent
out-of-bounds iteration.
[ ... ]
> @@ -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]
Does this silently truncate the 64-bit offset?
The off argument is a 64-bit loff_t, but iov_offset is a size_t (which is 32
bits on 32-bit platforms). Any offset >= 4GB will be silently truncated here.
Unlike ITER_XARRAY which uses a separate 64-bit xarray_start union field,
ITER_DMABUF_MAP doesn't store this absolute offset anywhere else.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791336930.git.asml.silence@gmail.com?part=2
next prev parent reply other threads:[~2026-10-07 1:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 1:42 [PATCH v9 00/13] Add dmabuf read/write via io_uring Pavel Begunkov
2026-10-07 1:42 ` [PATCH v9 01/13] dma-buf: introduce initial file I/O infrastructure Pavel Begunkov
2026-10-07 1:52 ` sashiko-bot
2026-10-07 1:42 ` [PATCH v9 02/13] iov_iter: add iterator type for dmabuf maps Pavel Begunkov
2026-10-07 1:57 ` sashiko-bot [this message]
2026-10-07 1:42 ` [PATCH v9 03/13] block: always adjust bi_offset on bio_advance_iter Pavel Begunkov
2026-10-07 1:42 ` [PATCH v9 04/13] block: introduce dma map backed bio type Pavel Begunkov
2026-10-07 1:59 ` sashiko-bot
2026-10-07 1:42 ` [PATCH v9 05/13] block: add dma-buf support for raw bdev Pavel Begunkov
2026-10-08 12:27 ` Anuj Gupta/Anuj Gupta
2026-10-07 1:42 ` [PATCH v9 06/13] nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl Pavel Begunkov
2026-10-07 1:42 ` [PATCH v9 07/13] nvme-pci: implement dma-buf backed requests Pavel Begunkov
2026-10-07 2:01 ` sashiko-bot
2026-10-07 1:42 ` [PATCH v9 08/13] nvme-pci: add SGL support for the dmabuf path Pavel Begunkov
2026-10-07 2:00 ` sashiko-bot
2026-10-07 1:42 ` [PATCH v9 09/13] io_uring/rsrc: introduce buf registration structure Pavel Begunkov
2026-10-07 1:42 ` [PATCH v9 10/13] io_uring/rsrc: extend buffer update Pavel Begunkov
2026-10-07 1:51 ` sashiko-bot
2026-10-07 1:42 ` [PATCH v9 11/13] io_uring/rsrc: add uncloneable regbuf flag Pavel Begunkov
2026-10-07 1:42 ` [PATCH v9 12/13] io_uring/rsrc: add regbuf import flags Pavel Begunkov
2026-10-07 1:42 ` [PATCH v9 13/13] io_uring/rsrc: add dmabuf backed registered buffers Pavel Begunkov
2026-10-07 1:55 ` 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=sashiko-outbox-162575@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