From: sashiko-bot@kernel.org
To: "Bobby Eshleman" <bobbyeshleman@gmail.com>
Cc: media-ci@linuxtv.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH net-next v8 1/3] net: devmem: allow rx-page-size > PAGE_SIZE per dmabuf binding
Date: Thu, 06 Aug 2026 20:43:24 +0000 [thread overview]
Message-ID: <20260806204324.ACEF21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-tcpdm-large-niovs-v8-1-3e0225e2808c@meta.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Truncation of 64-bit DMA addresses to 32-bit unsigned long causes allocator state and memory corruption.
- [High] Valid DMA address 0 is treated as an allocation failure, causing a permanent resource leak and kernel panic.
--
--- Patch [1]: [PATCH net-next v8 1/3] net: devmem: allow rx-page-size > PAGE_SIZE per dmabuf binding ---
commit aedd523e1f497a9daaf91448a092f69629705696
Author: Bobby Eshleman <bobbyeshleman@meta.com>
net: devmem: allow rx-page-size > PAGE_SIZE per dmabuf binding
This commit introduces a netlink attribute to allow setting a larger
dmabuf rx-page-size for the page_pool. The value must be a power of two
and greater than or equal to PAGE_SIZE.
> diff --git a/net/core/devmem.c b/net/core/devmem.c
> index 957d6b96216b3..f4d60654ce7fd 100644
> --- a/net/core/devmem.c
> +++ b/net/core/devmem.c
[ ... ]
> @@ -87,13 +93,14 @@ struct net_iov *
> net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
> {
> struct dmabuf_genpool_chunk_owner *owner;
> unsigned long dma_addr;
> struct net_iov *niov;
> ssize_t offset;
> ssize_t index;
>
> - dma_addr = gen_pool_alloc_owner(binding->chunk_pool, PAGE_SIZE,
> + dma_addr = gen_pool_alloc_owner(binding->chunk_pool,
> + 1UL << binding->niov_shift,
> (void **)&owner);
> if (!dma_addr)
> return NULL;
[Severity: High]
This isn't a bug introduced by this patch, but does this check incorrectly
handle a valid allocation when the dmabuf is mapped at DMA address 0?
Since gen_pool_alloc_owner() can return 0 on success if the chunk starts at
virtual address 0, checking for !dma_addr might treat a valid DMA address 0
as an allocation failure.
This could cause the allocation to leak in the pool without a tracking net_iov.
Later, when the dmabuf is unbound, gen_pool_destroy() will check that all
chunks are free and could hit a BUG_ON if this allocation was leaked.
>
> offset = dma_addr - owner->base_dma_addr;
> - index = offset / PAGE_SIZE;
> + index = offset >> binding->niov_shift;
> niov = &owner->area.niovs[index];
[Severity: High]
This is a pre-existing issue, but can this lead to an out-of-bounds array
access on 32-bit platforms with 64-bit DMA addresses (e.g., LPAE/PAE)?
Since dma_addr is derived from gen_pool_alloc_owner(), which returns an
unsigned long, it will be a 32-bit value on 32-bit systems.
If base_dma_addr is 64-bit and the actual address is above 4GB, the truncated
dma_addr subtracted from the 64-bit base_dma_addr would result in a massive
underflow.
Could this huge offset result in indexing out of bounds when initializing
niovs[index]?
[ ... ]
> @@ -288,7 +295,7 @@ net_devmem_bind_dmabuf(struct net_device *dev, void *vdev,
>
> owner->area.base_virtual = virtual;
> owner->base_dma_addr = dma_addr;
> - owner->area.num_niovs = len / PAGE_SIZE;
> + owner->area.num_niovs = len >> niov_shift;
> owner->binding = binding;
>
> err = gen_pool_add_owner(binding->chunk_pool, dma_addr,
> dma_addr, len, dev_to_node(&dev->dev),
> owner);
[Severity: High]
This isn't a bug introduced by this patch, but does calling
gen_pool_add_owner() silently truncate the 64-bit DMA address on 32-bit
systems?
The gen_pool_add_owner() function takes an unsigned long for the virt
argument. When passing dma_addr_t dma_addr on 32-bit architectures, this
might truncate the upper 32 bits of the DMA address.
If a DMA address exceeds 4GB, could this truncation cause overlapping virtual
address ranges in the gen_pool?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-tcpdm-large-niovs-v8-0-3e0225e2808c@meta.com?part=1
next prev parent reply other threads:[~2026-08-06 20:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 20:42 [PATCH net-next v8 0/3] net: devmem: allow rx-buf-size > PAGE_SIZE per binding Bobby Eshleman
2026-08-05 20:42 ` [PATCH net-next v8 1/3] net: devmem: allow rx-page-size > PAGE_SIZE per dmabuf binding Bobby Eshleman
2026-08-06 20:43 ` sashiko-bot [this message]
2026-08-05 20:42 ` [PATCH net-next v8 2/3] selftests/net: ncdevmem: add -b option to set rx-page-size on bind Bobby Eshleman
2026-08-05 20:42 ` [PATCH net-next v8 3/3] selftests/net: devmem.py: add check_rx_large_niov Bobby Eshleman
2026-08-08 1:40 ` [PATCH net-next v8 0/3] net: devmem: allow rx-buf-size > PAGE_SIZE per binding patchwork-bot+netdevbpf
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=20260806204324.ACEF21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bobbyeshleman@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