Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch adds `bool busy` to memory_provider_ops->uninstall()
and documents it as "If @busy is true, closing @rxq failed and…
- [Medium] The commit message describes this as a fix for an older
defect: "netif_rxq_cleanup_unlease() currently discards the return…
--
net: propagate busy status on memory provider uninstall
This patch adds a bool busy argument to memory_provider_ops->uninstall().
netif_rxq_cleanup_unlease() sets it from the __netif_mp_close_rxq()
result. Devmem records failed closes in a new binding->rxq_busy flag and
defers the dma_buf unmap while any queue of the binding failed to close.
> netif_rxq_cleanup_unlease() currently discards the return value of
> __netif_mp_close_rxq(), so memory providers cannot tell whether closing
> a leased queue failed and hardware may still be using the page pool.
[Severity: Medium]
Is this an older defect, or one that came in earlier in this series?
At the baseline, mp_dmabuf_devmem_uninstall() only unmapped behind a lease
guard:
if (!rxq->lease)
net_devmem_dmabuf_binding_unmap(binding);
At that point netif_rxq_cleanup_unlease() passed virt_rxq, whose ->lease
is still set, so the unlease path never unmapped.
Commit c4466d2c3e77 ("net: devmem: unmap dma_buf synchronously on queue
uninstall") added that guard for this case: "except when a leased queue is
unleased: the physical device is still registered and, if restarting its
queue failed, may still be using the binding."
The earlier series patch "net: devmem: resolve leased RX queues to
physical device on bind" did three things:
- dropped the guard
- made the unmap unconditional once bound_rxqs is empty
- switched netif_rxq_cleanup_unlease() to pass phys_rxq
It still ignored the __netif_mp_close_rxq() result.
In that commit, and in "net: devmem: synchronize and unmap all device
bindings on unregister", a failed leased-queue close during unlease
appears to lead to this:
netdev_rx_queue_unlease()
netif_rxq_cleanup_unlease()
__netif_mp_close_rxq() <- netdev_rx_queue_reconfig() fails
__netif_mp_uninstall_rxq(phys_rxq, ...)
mp_dmabuf_devmem_uninstall()
net_devmem_dmabuf_binding_unmap()
dma_buf_unmap_attachment()
dma_buf_unpin()
dma_buf_detach()
The physical RX queue is still running on the old devmem page pool when
this happens.
Could the busy/rxq_busy plumbing be folded into, or placed before, "net:
devmem: resolve leased RX queues to physical device on bind"? Then the
!rxq->lease guard would be replaced in one step, with no bisect window
where DMA can happen after unmap. If not, could the commit message at
least name the series patch that introduced the regression?
> diff --git a/include/net/page_pool/memory_provider.h b/include/net/page_pool/memory_provider.h
> index bceb5f7740e2f..82eac3feefc94 100644
> --- a/include/net/page_pool/memory_provider.h
> +++ b/include/net/page_pool/memory_provider.h
> @@ -26,7 +26,12 @@ struct memory_provider_ops {
> void (*destroy)(struct page_pool *pool);
> int (*nl_fill)(void *mp_priv, struct sk_buff *rsp,
> struct netdev_rx_queue *rxq);
> - void (*uninstall)(void *mp_priv, struct netdev_rx_queue *rxq);
> + /* Called under netdev_lock(rxq->dev) on device unregister or queue
> + * unlease. If @busy is true, closing @rxq failed and hardware may
> + * still be using the page pool.
> + */
> + void (*uninstall)(void *mp_priv, struct netdev_rx_queue *rxq,
> + bool busy);
> };
>
> bool net_mp_niov_set_dma_addr(struct net_iov *niov, dma_addr_t addr);
> diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
> index 20597bfa146d6..ed44835a783b5 100644
> --- a/io_uring/zcrx.c
> +++ b/io_uring/zcrx.c
> @@ -1457,7 +1457,8 @@ static int io_pp_nl_fill(void *mp_priv, struct sk_buff *rsp,
> return 0;
> }
>
> -static void io_pp_uninstall(void *mp_priv, struct netdev_rx_queue *rxq)
> +static void io_pp_uninstall(void *mp_priv, struct netdev_rx_queue *rxq,
> + bool busy)
> {
> struct io_zcrx_ifq *ifq = mp_priv;
>
[Severity: High]
The new comment above says that when busy is true, hardware may still be
using the page pool. io_pp_uninstall() never reads busy, though, and
still unmaps every time:
io_uring/zcrx.c:io_pp_uninstall() {
struct io_zcrx_ifq *ifq = mp_priv;
guard(mutex)(&ifq->pp_lock);
io_zcrx_unmap_areas(ifq);
io_zcrx_drop_netdev(ifq);
}
Can zcrx reach the busy=true path? zcrx_register_netdev() calls
netif_mp_open_rxq(). That function resolves a leased virtual queue to the
physical queue and installs io_uring_pp_zc_ops on phys_rxq.
When the netkit device is then deleted:
netdev_rx_queue_unlease()
netif_rxq_cleanup_unlease()
__netif_mp_close_rxq() <- netdev_rx_queue_reconfig() fails
__netif_mp_uninstall_rxq(phys_rxq, &p, true)
io_pp_uninstall()
io_zcrx_unmap_areas()
__io_zcrx_unmap_area()
The old hardware queue keeps using the zcrx page pool in either failure
case:
- a failure in kvzalloc, ndo_queue_mem_alloc,
page_pool_check_memory_provider or ndo_queue_stop leaves the old
queue untouched
- a start failure restarts the old queue with old_mem
__io_zcrx_unmap_area() then sets each niov DMA address to 0 with
net_mp_niov_set_dma_addr(niov, 0). It also calls dma_unmap_sgtable() or
io_unmap_dmabuf().
None of io_pp_zc_alloc_netmems(), io_zcrx_ring_refill() or
io_zcrx_refill_slow() checks area->is_mapped. Descriptors that were
already posted still point at the unmapped IOVAs.
Could the NIC then DMA into any of these?
- unmapped or reused IOVAs
- freed swiotlb slots
- physical address 0, when there is no IOMMU
io_close_queue() follows the same pattern: it ignores the return value of
netif_mp_close_rxq() and then calls io_zcrx_unmap_areas().
The commit message only says "Existing io_uring/zcrx uninstall behavior
is left unchanged". Should io_pp_uninstall() skip or defer
io_zcrx_unmap_areas() when busy is set, as mp_dmabuf_devmem_uninstall()
now does? If zcrx is meant to stay as it is, could the commit message say
why that is safe, and could the io_uring maintainers be asked about it?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40google.com