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 v11 04/13] block: introduce dma map backed bio type
Date: Wed, 14 Oct 2026 11:21:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-171194@kernel.org> (raw)
In-Reply-To: <39b964cf7510f42755188563da63d3d5acaf2aa9.1791975048.git.asml.silence@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] block: type confusion in blk_rq_cur_bytes() due to bio_has_data() including REQ_DMABUF
--
commit 338a7d60f029eb7fdd6fca422f1d54a04222c016
Author: Pavel Begunkov <asml.silence@gmail.com>
block: introduce dma map backed bio type
This patch introduces a dma map backed bio type to support pre-mapped
buffers without requiring a generic bio_vec. It repurposes the bi_io_vec
space in struct bio to store a dma_buf_io_map when the REQ_DMABUF flag
is set. It also adds specific splitting logic based on the minimum
segment size provided by the map.
[ ... ]
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 98e21b4cbf328..0cc09b975d8ff 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -233,7 +233,12 @@ struct bio {
> atomic_t __bi_remaining;
>
> /* The actual vec list, preserved by bio_reset() */
> - struct bio_vec *bi_io_vec;
> + union {
> + struct bio_vec *bi_io_vec;
> + /* Driver specific dma map, valid IFF REQ_DMABUF is set */
> + struct dma_buf_io_map *bi_dmabuf_map;
> + };
> +
[Severity: High]
Does this union introduce type confusion when existing block layer helpers
check bio_has_data()?
Because REQ_DMABUF is a flag rather than an operation type, bio_has_data() in
include/linux/bio.h will still return true for read/write requests carrying
this flag.
When a driver partially completes a REQ_DMABUF request, blk_update_request()
calls blk_rq_cur_bytes() in include/linux/blk-mq.h to verify the size of the
remaining segment:
include/linux/blk-mq.h:blk_rq_cur_bytes() {
...
if (!bio_has_data(rq->bio))
return rq->bio->bi_iter.bi_size;
return bio_iovec(rq->bio).bv_len;
}
Since bio_has_data() is true, blk_rq_cur_bytes() invokes
bio_iovec(rq->bio).bv_len. This macro treats the bio->bi_dmabuf_map pointer
as an array of struct bio_vec, reading bv_len from the overlapping bytes of
the dma_buf_io_map struct.
If this garbage value is larger than the remaining blk_rq_bytes(req), it
corrupts req->__data_len and can trigger out-of-bounds memory access or
panics when the request resumes. Should bio_has_data() be updated to
exclude REQ_DMABUF, or is there another way to prevent blk_rq_cur_bytes()
from blindly dereferencing the dma map as a bio_vec?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791975048.git.asml.silence@gmail.com?part=4
next prev parent reply other threads:[~2026-10-14 11:21 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 11:01 [PATCH v11 00/13] Add dmabuf read/write via io_uring Pavel Begunkov
2026-10-14 11:01 ` [PATCH v11 01/13] dma-buf: introduce initial file I/O infrastructure Pavel Begunkov
2026-10-14 11:13 ` sashiko-bot
2026-10-14 12:30 ` Christian König
2026-10-14 13:06 ` Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 02/13] iov_iter: add iterator type for dmabuf maps Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 03/13] block: always adjust bi_offset on bio_advance_iter Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 04/13] block: introduce dma map backed bio type Pavel Begunkov
2026-10-14 11:21 ` sashiko-bot [this message]
2026-10-14 13:03 ` Pavel Begunkov
2026-10-14 13:15 ` Christoph Hellwig
2026-10-14 16:43 ` Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 05/13] block: add dma-buf support for raw bdev Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 06/13] nvme-pci: rename nvme_pci_sgl_set_data to nvme_pci_dma_iter_set_sgl Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 07/13] nvme-pci: implement dma-buf backed requests Pavel Begunkov
2026-10-14 11:26 ` sashiko-bot
2026-10-14 13:16 ` Christoph Hellwig
2026-10-14 11:02 ` [PATCH v11 08/13] nvme-pci: add SGL support for the dmabuf path Pavel Begunkov
2026-10-14 11:23 ` sashiko-bot
2026-10-14 13:16 ` Christoph Hellwig
2026-10-14 11:02 ` [PATCH v11 09/13] io_uring/rsrc: introduce buf registration structure Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 10/13] io_uring/rsrc: extend buffer update Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 11/13] io_uring/rsrc: add uncloneable regbuf flag Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 12/13] io_uring/rsrc: add regbuf import flags Pavel Begunkov
2026-10-14 11:02 ` [PATCH v11 13/13] io_uring/rsrc: add dmabuf backed registered buffers Pavel Begunkov
2026-10-14 11:18 ` sashiko-bot
2026-10-14 13:40 ` Jens Axboe
2026-10-14 13:43 ` [PATCH v11 00/13] Add dmabuf read/write via io_uring Jens Axboe
2026-10-14 14:37 ` Anuj gupta
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-171194@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.