Created attachment 265198 [details] kernel core dump summary A colleague reported that his system (a newish Thinkpad X1 Carbon?) would crash with 16-CURRENT unless tb(4) is blacklisted during boot. See attached core file. Debugging yields a crash in router_complete_intr() at the assignment sc = cmd->sc; The entire object cmd is filled with 0xdeadc0de, possibly indicating a use-after-free condition or some sort of uninitialised memory. A full kernel crash dump is available to developers on request. This should be fixed for 15.0 if possible as it prevents recent laptops from booting.
This looks like the driver did an error-driven detach in the middle of talking to the hardware, and an interrupt happened after driver memory was freed. Detach should be fixed to avoid this race and use-after-free pattern. Additionally, alpine ridge hardware support should be either removed entirely or made experimentally conditional and opt-in, since the icm code was removed and the alpine ridge hardware is not easy to develop on.
I believe I already fixed the crash when you kldload the driver via devmatch here: commit 561571d480679933287a6d21c6929c39a7963857 Author: John Baldwin <jhb@FreeBSD.org> Date: Wed Oct 29 14:56:17 2025 -0400 nhi: Fix a race with interrupt teardown during detach When nhi fails to attach on one of my systems (X1 Carbon 6th gen), an interrupt races with the teardown code such that the rings have been freed by nhi_detach() before an interrupt triggers. At the time of the crash, the thread invoking nhi_attach() is blocked in bus_teardown_intr() from nhi_pci_free() waiting for the interrupt thread to finish executing the handler. To fix, don't just disable the interrupts in nhi_detach(), but actually tear the handlers down and disable MSI-X before freeing the rings. Reviewed by: obiwac Differential Revision: https://reviews.freebsd.org/D53201 I still get a separate crash during boot if I load the driver from the boot loader, but I suspect the crash you are seeing here is the one I fixed above.
(In reply to John Baldwin from comment #2) My colleague confirms that with a fresh kernel, the crash goes away if tb.ko is loaded late in the boot, but persists if loaded from loader.conf. Shall I ask him to supply another crash dump?
Yes, please, another debug log will be useful.
Created attachment 265219 [details] kernel core dump summary II Seems to crash in the same location. Note sc = 0xdeadc0dedeadc0de at crash time. Kernel commit base 3f5f52216f7e583aeb5580b13ba0f87e29d1ee43.
Yes, as I noted, I still get a crash if loaded at boot. The solution for now is to just not do that. I did get another panic on boot that I've also pushed a fix to the tree for, but the use after free in the interrupt handler at boot I have not tracked down. It is as Scott notes still the case that an error happens during attach and there is a race with interrupt teardown still.
Thanks to you both for working on this. My recommendation for the near term is to either disconnect the code from the build, or put it on a non-allowed module list. I appreciate the interest in the code, but with the ICM removed, the AR, TR, and ICL support doesn't do anything that's useful in a user-facing way. Until an HCM is written, until a proper vendor-specific USB-PD driver is written, until USB3 is integrated for both Alt-Mode and tunneling operation, until a vendor-specific display cross-bar driver is written..... etc.... etc... this driver doesn't enable any functional capabilities. It is the slab of concrete on which one builds a house, it is not a house itself.
hey, thanks for working on the issue. I'm the colleague mentioned and I got my hands on a bugzilla account now. If you need anything, I can provide whatever is necessary. Thank you all for taking the time for working on it.
I have removed these in https://reviews.freebsd.org/D52861, and have removed the MODULE_PNP_INFO() too for the time being.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5bd839792b6a6afacb50f782b6013100b5ff9110 commit 5bd839792b6a6afacb50f782b6013100b5ff9110 Author: Aymeric Wibo <obiwac@FreeBSD.org> AuthorDate: 2025-12-15 23:14:08 +0000 Commit: Aymeric Wibo <obiwac@FreeBSD.org> CommitDate: 2025-12-15 23:23:35 +0000 thunderbolt: Remove PNP info So it isn't matched by devmatch(8) and automatically loaded. The PNP info will be readded once the USB4 driver is more complete. PR: 290827 Reported by: fuz, Marco Siedentopf <siedentm@me.com> Fixes: 2ed9833791f2 (thunderbolt: Import USB4 code) Sponsored by: The FreeBSD Foundation sys/dev/thunderbolt/nhi_pci.c | 2 -- sys/dev/thunderbolt/tb_pcib.c | 2 -- 2 files changed, 4 deletions(-)
Should be fine now!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=bb36c457ea49d80ca3109ef25ca41a614f9738b8 commit bb36c457ea49d80ca3109ef25ca41a614f9738b8 Author: Aymeric Wibo <obiwac@FreeBSD.org> AuthorDate: 2026-04-15 12:04:17 +0000 Commit: Aymeric Wibo <obiwac@FreeBSD.org> CommitDate: 2026-04-15 12:10:24 +0000 thunderbolt: Support generic USB4 NHIs Check a PCI device's class, subclass, and progif to figure out if it is a USB4 NHI. nhi_identifiers is completely removed as only these generic USB4 NHIs are supported anyway, and all remnants of ICM-supporting code are removed too. All devices now use the HCM. PR: 290827 Reviewed by: jhb, ngie Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52861 sys/dev/pci/pcireg.h | 1 + sys/dev/thunderbolt/nhi.c | 49 ++--------------- sys/dev/thunderbolt/nhi_pci.c | 121 ++---------------------------------------- sys/dev/thunderbolt/nhi_var.h | 18 ------- sys/dev/thunderbolt/tb_pcib.c | 12 ----- 5 files changed, 9 insertions(+), 192 deletions(-)