Skip to content

Upstream notes

Problems found in this project that are candidates for reporting to upstream projects. Before sending any of them: re-check the current state, search manually for an existing report/patch (lore.kernel.org blocks automated searches), and check the project's contribution rules.

1. Linux: ntb_tool peer_mw_trans rejects hexadecimal addresses (v7.0-rc1 regression)

Status: v1 sent 2026-11-26, tracked by regzbot; reviewed by Koichiro Den, who asked to keep rejecting a negative address. v2 sent 2026-11-27 (search lore.kernel.org/ntb for "accept hexadecimal addresses").

Symptom. tools/testing/selftests/ntb/ntb_test.sh stops in the MW tests with echo: write error: Invalid argument. It happens on every NTB hardware; here it was seen on the virtual qntb device in a single-VM loopback setup.

Cause. The selftest writes the DMA Address value it reads from ntb_tool's mw_trans<N> file (%pad, i.e. 0x…) unchanged into the peer's peer_mw_trans<N> file. tool_peer_mw_trans_write() parses the input with sscanf(buf, "%llu:%zu", …); in the kernel's vsscanf, %u is always base 10, so 0x… is read as 0, : does not match, sscanf returns 1 and the write fails with -EINVAL. The usage example in ntb_tool.c itself (echo 0xADD0BA5E:16384 > peer_mw_trans0) is rejected as well.

Origin. From 2017 to v6.19 the format was "%lli:%zi" (accepts hex). 21fbdc4d0b1e ("ntb/ntb_tool: correct sscanf format for u64 and size_t in tool_peer_mw_trans_write") changed it to "%llu:%zu"; its commit message says %llu also parses hex, which is not true. Affected: v7.0-rc1 – v7.3.x, mainline (v7.4-rc4), linux-next. 5.15.y – 6.19.y are not affected. (The commit id and dates are the values the verifying agent read from the upstream git history; confirm with git log -S'%llu:%zu' drivers/ntb/test/ntb_tool.c before sending.)

Fix (v2, upstream/ntb_tool-hex/fix.diff): split the input at : with strsep() and parse the address with kstrtou64(…, 0, …), which accepts decimal and hexadecimal but not a negative value (v1 went back to %lli, which accepted -1 as an address again).

%zu is kept (that commit's -1 → SIZE_MAX rationale stands). The other numeric inputs of ntb_tool (%lli, kstrto*_from_user(…, 0)) accept every base too; the fix is consistent with them. Tags: Fixes: 21fbdc4d0b1e (...), Cc: stable@vger.kernel.org. Recipients: the NTB maintainers (Jon Mason, Dave Jiang, Allen Hubbe), ntb@lists.linux.dev; confirm with scripts/get_maintainer.pl.

Evidence. tests/p5-selftest-fix.sh, in the same VM: 1. unmodified ntb_test.sh + the kernel's ntb_tool → fails in the MW test, 2. unmodified ntb_test.sh + ntb_tool with fix.diff applied → passes completely. 3. with the fix, -1:16384 is rejected.

Meanwhile, the project's own test set (tests/p5-selftest.sh) converts the address to decimal with $((…)) in the initramfs copy of the script; the source tree is not modified.

2. Linux: use-after-free when removing ntb_tool (since v4.16)

Status: sent to the NTB maintainers and lists on 2026-11-26 (search lore.kernel.org/ntb for "fix use-after-free of memory window debugfs").

Symptom. If ntb_tool is removed (rmmod, or the NTB device goes away) while an inbound (mw_trans<N>) or outbound (peer_mw_trans<N>) memory window is set up, the kernel oopses:

BUG: kernel NULL pointer dereference, address: 0000000000000140
 __lock_acquire ← down_write_nested ← __simple_recursive_removal
 ← debugfs_remove ← tool_free_mw / tool_free_peer_mw ← tool_clear_mws ← tool_remove

Seen twice in this project: in the cleanup of a selftest left half-finished by regression 1 (tool_free_mw), and in a deliberate reproduction (tool_free_peer_mw). On a KASAN kernel it shows up as KASAN: null-ptr-deref in range [0x0000000000000140-0x0000000000000147] (the killed dentry's d_inode is NULL).

Cause. tool_remove() first deletes the whole debugfs tree with debugfs_remove_recursive() through tool_clear_dbgfs(); the peer<N>/mw<N> and peer<N>/peer_mw<N> files are in this tree. Then tool_clear_mws() calls debugfs_remove() again on the stored (now freed) dentries of these files.

Origin. 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support", shipped in v4.16): the previous version freed the MWs first and debugfs last. Not fixed in mainline or linux-next (the state the verifier read; confirm before sending).

Proposed fix (upstream/ntb_tool-remove-uaf/fix.diff): in tool_clear_dbgfs(), after the recursive removal, set tc->dbgfs_dir and all outmws[].dbgfs_file / peers[].inmws[].dbgfs_file pointers to NULL. Removing debugfs first is kept (this ends user-space accesses); MW memory is still freed in tool_clear_mws(). Tags: Fixes: 7f46c8b3a552 (...), Cc: stable@vger.kernel.org.

Evidence. tests/p5-ntb_tool-uaf.sh: with inbound and outbound MWs set up, the fixed ntb_tool is removed without an oops (lockdep kernel; the test harness also scans for kernel warnings). Running the same script with the kernel's own module reproduced the oops (reverse check, by hand).

3. QEMU: the vfio-user device does not block migration

Status: reported as https://gitlab.com/qemu-project/qemu/-/work_items/5002 (2026-11-26), with a pointer in the migration series thread on qemu-devel. The maintainers agreed to a separate blocker until the series lands; a blocker patch was sent on 2026-11-27 (search lore.kernel.org/qemu-devel for "vfio-user: block migration").

Symptom. A VM with a vfio-user-pci device attached to a vfio-user server that does not support migration can be live-migrated without a warning; the device's state in the server and QEMU's copy of PCI config (BAR addresses, COMMAND, MSI-X) are lost. scripts/run-migration.sh shows this: QMP migrate returns {} and query-migrate says "active". (A 9p share blocks migration by itself, so the test uses a VM without 9p.) --only-migratable does not help either.

Cause. Unlike vfio-pci, vfio_user_pci_realize() (hw/vfio-user/pci.c) does not call vfio_migration_realize(); that is where the blocker is added. There is no vmsd or migrate_add_blocker for vfio-user either. Same in QEMU 11.1.3, 11.2.0-rc1 and master.

Upstream state. Patch 8/8 of the series "[PATCH v2 0/8] vfio-user: live migration support" (2026-09-11) adds this call, but the series has stalled (the author's address bounces, and the VFIO maintainer asked whether anyone is taking it over).

Proposed path. A GitLab issue (reproduced on the latest release with a plain QEMU command line) and a link to the stalled series. If a patch is needed, adding an explicit blocker through vbasedev->migration_blocker is the smallest fix.

Impact on this project. ntbd cannot block migration on its side (QEMU does not ask the server). The QEMU-internal device (P7) uses migrate_add_blocker().