[PATCH v3 0/2] net: io_uring/zcrx: call netdev_queue_get_dma_dev() under instance lock
From: David Wei <hidden>
Date: 2025-11-01 02:24:52
Also in:
io-uring
netdev ops must be called under instance lock or rtnl_lock, but
io_register_zcrx_ifq() isn't doing this for netdev_queue_get_dma_dev().
Fix this by taking the instance lock using netdev_get_by_index_lock().
netdev_get_by_index_lock() isn't available outside net/ by default, so
the first patch is a prep patch to export this under linux/netdevice.h.
Extended the instance lock section to include attaching a memory
provider. Could not move io_zcrx_create_area() outside, since the dmabuf
codepath IORING_ZCRX_AREA_DMABUF requires ifq->dev.
The netdev instance lock is taken first, followed by holding a ref. On
err, this is freed in LIFO order: put ref then unlock. After
successfully opening the mp on an rxq, the instance lock is unlocked and
ifq->if_rxq is set to a valid value. If there are future errs,
io_zcrx_ifq_free() will put the ref.
v3:
- do not export netdev_get_by_index_lock()
- fix netdev lock/ref cleanup
v2:
- add Fixes tag
- export netdev_get_by_index_lock()
- use netdev_get_by_index_lock() + netdev_hold()
- extend lock section to include net_mp_open_rxq()
David Wei (2):
net: export netdev_get_by_index_lock()
net: io_uring/zcrx: call netdev_queue_get_dma_dev() under instance
lock
include/linux/netdevice.h | 1 +
io_uring/zcrx.c | 16 ++++++++++------
net/core/dev.h | 1 -
3 files changed, 11 insertions(+), 7 deletions(-)
--
2.47.3