Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: almasrymina@google.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
	horms@kernel.org, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, sdf.kernel@gmail.com,
	bobbyeshleman@meta.com, razor@blackwall.org,
	daniel@iogearbox.net, dw@davidwei.uk, asml.silence@gmail.com,
	axboe@kernel.dk, bestswngs@gmail.com, io-uring@vger.kernel.org,
	hawk@kernel.org, ilias.apalodimas@linaro.org
Subject: Re: [PATCH net-next v5 3/6] net: devmem: resolve leased RX queues to physical device on bind
Date: Sun, 06 Dec 2026 00:07:40 +0000	[thread overview]
Message-ID: <179651566095.3148.8405401259463150987@kernel.org> (raw)
In-Reply-To: <20261204231030.3815575-4-almasrymina@google.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Commit "net: devmem: resolve leased RX queues to physical device
  on bind" fixes a memory-safety bug in leased-queue devmem RX teardown,…

--

net: devmem: resolve leased RX queues to physical device on bind

At bind-rx time, this commit resolves leased RX queues to the physical
net_device and its physical rx_queue indices. It holds
netdev_lock(virt_dev) and then netdev_lock(phys_dev) across the DMA
device lookup, the dmabuf mapping and the queue opens.

phys_dev and phys_rxq are stored in the binding so that teardown paths
serialize on the physical device lock. The rxq->mp_params clearing moves
into __netif_mp_uninstall_rxq().

> - When the physical device unregisters first,
>   dev_memory_provider_uninstall(phys_dev) passes phys_rxq to
>   mp_dmabuf_devmem_uninstall(), which searches binding->bound_rxqs for
>   virt_rxq, fails to match, and leaves the dmabuf mapped.

[ ... ]

> These issues were identified by code inspection and selftest development
> while extending devmem unregister teardown to leased queues; they have not
> been observed in production or tested on real hardware. Verified with
> netdevsim and netkit selftests in nl_netdev.py and nk_qlease.py.

[Severity: Low]
Does "leaves the dmabuf mapped" cover the full consequence here? And
should this patch carry Fixes: tags?

Before this patch, when the physical device unregisters first, the
cascaded unlease path is the one that matches virt_rxq:

netif_rxq_cleanup_unlease(phys_rxq, virt_rxq)
  __netif_mp_uninstall_rxq(virt_rxq, &p)
    mp_dmabuf_devmem_uninstall(binding, virt_rxq)

That call empties bound_rxqs and clears binding->dev. It skips the unmap
because virt_rxq->lease is still set:

		if (xa_empty(&binding->bound_rxqs)) {
			if (!rxq->lease)
				net_devmem_dmabuf_binding_unmap(binding);
			ASSERT_EXCLUSIVE_WRITER(binding->dev);
			WRITE_ONCE(binding->dev, NULL);
		}

net_devmem_dev_unregister() does not unmap it either. binding->dev does
not match phys_dev, and the leasee device is skipped.

So the dma_buf attachment stays mapped while the physical dma_dev is
freed. When the netlink socket is closed later, this call chain would run
against the freed device:

__net_devmem_dmabuf_binding_free()->dma_buf_unmap_attachment()

This looks like the same slab-use-after-free in dma_unmap_sg_attrs()
that KASAN caught in commit c4466d2c3e77 ("net: devmem: unmap dma_buf
synchronously on queue uninstall").

Could the commit message describe this as a use-after-free rather than a
mapping leak? Tags like these would also let stable trees that carry the
queue lease support pick it up:

Fixes: 5602ad61ebee ("net: Proxy netif_mp_{open,close}_rxq for leased queues")
Fixes: c4466d2c3e77 ("net: devmem: unmap dma_buf synchronously on queue uninstall")

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204231030.3815575-1-almasrymina%40google.com

  reply	other threads:[~2026-12-06  0:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 23:10 [PATCH net-next v5 0/6] net: devmem: support leased RX and TX queues on netdev unregister Mina Almasry
2026-12-04 23:10 ` [PATCH net-next v5 1/6] net: guard leased queue ops against physical " Mina Almasry
2026-12-06  0:07   ` netdev-bot+sashiko
2026-12-04 23:10 ` [PATCH net-next v5 2/6] net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() Mina Almasry
2026-12-04 23:10 ` [PATCH net-next v5 3/6] net: devmem: resolve leased RX queues to physical device on bind Mina Almasry
2026-12-06  0:07   ` netdev-bot+sashiko [this message]
2026-12-04 23:10 ` [PATCH net-next v5 4/6] net: devmem: synchronize and unmap all device bindings on unregister Mina Almasry
2026-12-06  0:07   ` netdev-bot+sashiko
2026-12-04 23:10 ` [PATCH net-next v5 5/6] net: propagate busy status on memory provider uninstall Mina Almasry
2026-12-06  0:07   ` netdev-bot+sashiko
2026-12-04 23:10 ` [PATCH net-next v5 6/6] selftests: net: add leased devmem RX and TX netdev unregister tests Mina Almasry

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=179651566095.3148.8405401259463150987@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=almasrymina@google.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bestswngs@gmail.com \
    --cc=bobbyeshleman@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dw@davidwei.uk \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=io-uring@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=sdf.kernel@gmail.com \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    /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