From: sashiko-bot@kernel.org
To: "Bilal Hashim" <AeeSec@126.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-pci: validate dmabuf size and sg_table bounds in nvme_dma_buf_io_map()
Date: Tue, 01 Dec 2026 06:44:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-242719@kernel.org> (raw)
In-Reply-To: <179610715173.42980.4278125034253504647@126.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] nvme-pci: missing Fixes trailer for nvme_dma_buf_io_map() bounds
fix
--
commit 0f211451ecf8fb8b6438a1ca1c4bb449732f7069
Author: Bilal Hashim <AeeSec@126.com>
> nvme-pci: validate dmabuf size and sg_table bounds in nvme_dma_buf_io_map()
>
> In nvme_dma_buf_io_map():
>
> 1. ctx->dmabuf->size (size_t) is divided by NVME_CTRL_PAGE_SIZE and
> stored into a 32-bit unsigned nr_entries without checking for zero or
> overflow, and nvme_rq_setup_dmabuf_map() indexes the buffer via the
> 32-bit bio->bi_iter.bi_offset. Reject empty dma-bufs or dma-bufs
> larger than UINT_MAX.
> 2. When populating map->dma_list[] from the scatter-gather table, there
> is no bounds check against nr_entries. If the sg_table total DMA
> length exceeds nr_entries * NVME_CTRL_PAGE_SIZE, map->dma_list[i++]
> overflows the allocated buffer. Conversely, if the sg_table total DMA
> length is smaller than nr_entries * NVME_CTRL_PAGE_SIZE, trailing
> entries in map->dma_list[] remain uninitialized (kvmalloc_flex() does
> not zero-initialize) and could be programmed as arbitrary NVMe DMA
> addresses.
>
> Validate ctx->dmabuf->size before computing nr_entries, bounds-check
> each write into map->dma_list[], and verify that the entire dma_list was
> populated.
>
> Found by manual code inspection.
>
> Signed-off-by: Bilal Hashim <AeeSec@126.com>
[Severity: Low]
This fixes missing size and scatter-gather bounds checks in
nvme_dma_buf_io_map(). Should this include:
Fixes: ce5e386c1108 ("nvme-pci: implement dma-buf backed requests")
--
Sashiko AI review · https://sashiko.dev/#/patchset/179610715173.42980.4278125034253504647@126.com?part=1
prev parent reply other threads:[~2026-12-01 6:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 6:39 [PATCH] nvme-pci: validate dmabuf size and sg_table bounds in nvme_dma_buf_io_map() Bilal Hashim
2026-12-01 6:44 ` sashiko-bot [this message]
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-242719@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=AeeSec@126.com \
--cc=linux-nvme@lists.infradead.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