Re: [PATCH v4 00/15] NTB: ntb_transport: Miscellaneous fixes
From: Oguzhan KAYNAK
Date: Sun Dec 06 2026 - 02:15:18 EST
On Fri, Nov 27, 2026 at 11:05:18AM +0900, Koichiro Den wrote:
> This series attempts to fix miscellaneous issues in ntb_transport.
Tested on x86_64/KVM: two guests joined by an emulated NTB device
(qemu-ntb [1]), ntb_netdev over ntb_transport, use_dma=0 and 1,
ntb-next 0aa2e6bc39f1 with KASAN and lockdep.
Without the series I hit (matched to the patches by their changelogs;
the leak and the transport-context use-after-free under patch 15 also
checked with patches 1-14 only):
- patch 1: debugfs "already exists" on rebind
- patch 4: the link_work/link_cleanup deadlock (lockdep + hung task)
- patch 10: KASAN in ntb_transport_rxc_db() during unbind
- patch 13, step 3-(B): KASAN in ntb_qp_link_down_reset()
- patch 15: KASAN in ntb_transport_tx_free_entry() (via the DMA
completion callback), an RX skb leak (below), and a use-after-free
of the transport context in ntb_transport_link_cleanup_work()
during rmmod
The leak: unbinding ntb_transport while ntb_netdev is bound logs
"Freeing item from non-empty rx_pend_q" 100 times per unbind.
ntb_transport_free() frees the queues before ntb_bus_remove() removes
ntb_netdev, and ntb_transport_free_queue() frees the entries but not
the skbs ntb_netdev posted, so ntb_netdev cannot take them back with
ntb_transport_rx_remove(). SUnreclaim on that side went from 39 MB
before the first unbind to 589 MB after 41, about 13 MB per unbind.
With patches 1-14 it still grows (39 MB to 309 MB after 19 unbinds);
with patch 15 it does not. This is not in the patch 15 changelog;
maybe worth a line.
With the series:
- patch 1 test and step 3-(B): pass, 11 of 11 runs for 3-(B)
- unbind under load: 100 rounds with use_dma=0 (SUnreclaim stays
between 61 and 72 MB), 667 with use_dma=1 (in 10 runs; 3 of them
stopped early on the link-up race below, 2 on a stall of the test
script that has since been fixed)
- load/unload churn: 150 rounds with use_dma=0, 100 with use_dma=1
- no KASAN, lockdep or hung task report in any of these runs
While testing I also hit an older race, not caused by this series: the
link sometimes does not come up after both sides load ntb_transport,
when the link cleanup queued at probe time runs after the peer's
link-up. I am handling it separately, details and an RFC in [3].
Tests and the failure reports: [2]
[1] https://github.com/oguzhankynk/qemu-ntb
[2] https://github.com/oguzhankynk/qemu-ntb/blob/ntb-transport-teardown/docs/transport-teardown.md
[3] https://lore.kernel.org/r/20261206070959.8519-1-kaynak.oguzhan0@xxxxxxxxx/
Tested-by: Oguzhan KAYNAK <kaynak.oguzhan0@xxxxxxxxx>