All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3 0/4] net: devmem: fix RX and TX binding teardown on device unregistration
@ 2026-10-14 16:17 Mina Almasry
  2026-10-14 16:17 ` [PATCH net v3 1/4] net: devmem: unmap dma_buf synchronously on queue uninstall Mina Almasry
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mina Almasry @ 2026-10-14 16:17 UTC (permalink / raw)
  To: Jakub Kicinski, Mina Almasry, Pavel Begunkov, David Wei,
	Stanislav Fomichev, Taehee Yoo, Paolo Abeni, Kaiyuan Zhang,
	Bobby Eshleman, netdev, linux-kernel, linux-kselftest,
	linux-media, dri-devel
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Simon Horman,
	Shuah Khan, Sumit Semwal, Christian König, Daniel Borkmann,
	Nikolay Aleksandrov, Tariq Toukan, Kaifeng Wang, Dragos Tatulea

Fix two device-unregistration lifecycle bugs in devmem TCP bindings and
add netdevsim support plus selftests covering both RX and TX device
unregistration:

1. net: devmem: unmap dma_buf synchronously on queue uninstall
   Synchronously unmap and detach binding->attachment under binding->lock
   when the last RX queue is uninstalled in mp_dmabuf_devmem_uninstall(),
   and unmap RX bindings that were already unbound on NETDEV_UNREGISTER,
   preventing slab-use-after-free in dma_unmap_sg_attrs() when the binding
   is freed after dma_dev.

2. net: devmem: detach TX bindings on NETDEV_UNREGISTER
   Extend net_devmem_dev_unregister() to fully detach and unmap TX
   bindings when binding->dev unregisters, or clear binding->vdev alone
   when only a virtual device unregisters while binding->dev lives.

3. netdevsim: support devmem RX and TX bindings
   Enable PP_FLAG_DMA_MAP | PP_FLAG_ALLOW_UNREADABLE_NETMEM, 64-bit DMA mask
   on nsim_bus_dev, and NETMEM_TX_DMA on netdevsim so devmem RX/TX bindings
   can be exercised in software selftests.

4. selftests: net: add devmem RX and TX netdev unregister tests
   Add devmem_bind_rx_unregister_check and devmem_bind_tx_unregister_check
   to tools/testing/selftests/net/nl_netdev.py.

Cc: Tariq Toukan <tariqt@nvidia.com>
Cc: Kaifeng Wang <kaifengw@google.com>
Cc: Dragos Tatulea <dtatulea@nvidia.com>

---
v3:
- 1/4: Run the NETDEV_UNREGISTER walk under the netdev instance lock,
  and skip it when the device only moves to another netns. (Sashiko)
- 2/4: Detach all matching TX bindings, then synchronize_net() once
  before unmapping them. (Sashiko)
- 3/4: Only request page pool DMA mapping with CONFIG_HAS_DMA, refuse
  pp_hold on memory provider pools, and drop unreadable skbs in the
  software PSP checksum path. (Sashiko)
- 4/4: Check only the test's dma-buf in debugfs, skip instead of passing
  silently, clean up on errors, compute UDMABUF_CREATE per arch, and
  add the needed config options. (Sashiko, Dragos)
- Link to v2: https://lore.kernel.org/netdev/20261012174300.2338784-1-almasrymina@google.com/

v2:
- 1/4: Don't unmap when a leased queue is unleased. Keep bindings in
  net_devmem_dmabuf_bindings until freed, hidden from TX lookups by an
  xarray mark, and unmap unbound RX bindings on NETDEV_UNREGISTER. Update
  the binding->lock and binding->ref comments. (Sashiko)
- 2/4: Detach TX bindings from the same net_devmem_lock-protected walk,
  which now also covers unbound TX bindings, and clear the LIVE mark
  instead of erasing the ID. The walk no longer uses RCU or takes
  binding references (Stanislav).
- Link to v1: https://lore.kernel.org/netdev/20261010025532.839559-1-almasrymina@google.com/

Mina Almasry (4):
  net: devmem: unmap dma_buf synchronously on queue uninstall
  net: devmem: detach TX bindings on NETDEV_UNREGISTER
  netdevsim: support devmem RX and TX bindings
  selftests: net: add devmem RX and TX netdev unregister tests

 drivers/net/netdevsim/bus.c              |   1 +
 drivers/net/netdevsim/netdev.c           |  27 ++++-
 drivers/net/netdevsim/psp.c              |   5 +
 net/core/devmem.c                        | 143 ++++++++++++++++++++---
 net/core/devmem.h                        |  10 +-
 net/core/netdev-genl.c                   |   1 +
 tools/testing/selftests/net/config       |   4 +
 tools/testing/selftests/net/nl_netdev.py | 125 +++++++++++++++++++-
 8 files changed, 290 insertions(+), 26 deletions(-)


base-commit: 513444cc62e231a11c9b15ea88de0890da9b2b4f
-- 
2.56.0.176.g3575e65682-goog


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-10-15 19:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 16:17 [PATCH net v3 0/4] net: devmem: fix RX and TX binding teardown on device unregistration Mina Almasry
2026-10-14 16:17 ` [PATCH net v3 1/4] net: devmem: unmap dma_buf synchronously on queue uninstall Mina Almasry
2026-10-15 16:18   ` sashiko-bot
2026-10-15 19:21   ` netdev-bot+sashiko
2026-10-14 16:17 ` [PATCH net v3 2/4] net: devmem: detach TX bindings on NETDEV_UNREGISTER Mina Almasry
2026-10-15 19:21   ` netdev-bot+sashiko
2026-10-14 16:17 ` [PATCH net v3 3/4] netdevsim: support devmem RX and TX bindings Mina Almasry
2026-10-15 16:18   ` sashiko-bot
2026-10-15 19:21   ` netdev-bot+sashiko
2026-10-14 16:17 ` [PATCH net v3 4/4] selftests: net: add devmem RX and TX netdev unregister tests Mina Almasry

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.