Public bug reported:

On Kubuntu 24.04.5 LTS, kernel `7.0.0-42-generic` intermittently fails
to reach the desktop. The first kernel Oops is a NULL instruction fetch
at `RIP: 0010:0x0` during PCI driver binding. On one failed boot, the
journal records a Thunderbolt probe timeout before the Oops.

**Affected system**

- Ubuntu source package: `linux-hwe-7.0`, version `7.0.0-42.42~24.04.1`
- Board: Gigabyte Z890 AORUS ELITE X ICE, BIOS F19
- Thunderbolt controller: PCI `0000:00:0d.2`
- Root filesystem: LUKS-encrypted
- The stock failure log includes the out-of-tree `r8125` module and kernel 
taint flags `O` and `E`.

**Steps to reproduce**

Power on, boot `7.0.0-42-generic` with Thunderbolt enabled, and unlock
the encrypted root filesystem normally. The failure is intermittent. On
affected boots, device initialization stalls and the desktop does not
start.

**Expected behavior**

If the Thunderbolt controller fails to initialize, the driver should
clean up and return the probe error. Subsequent PCI driver binding
should continue without a kernel Oops.

**Observed behavior**

In the November 8 failed boot, the kernel recorded:

```text
[    2.704481] thunderbolt 0000:00:0d.2: probe with driver thunderbolt failed 
with error -110
[   18.256954] BUG: kernel NULL pointer dereference, address: 0000000000000000
[   18.256970] RIP: 0010:0x0
[   18.256984] notifier_call_chain+0x61/0xf0
[   18.256988] blocking_notifier_call_chain+0x41/0x70
[   18.256990] bus_notify+0x37/0x60
[   18.256994] driver_sysfs_add+0x1b/0xd0
```

The first Oops occurred during `intel_vsec` registration. An earlier
failed boot reached the same notifier call site during `snd_hda_intel`
registration. The fault registers and disassembly indicate a non-NULL
notifier block with a NULL callback and a NULL next pointer. On a
successful boot, a PCI notifier trace showed `tb_pci_notifier_fn` as the
last entry in the chain.

**Suspected cause and local patch**

The installed Thunderbolt module and the matching Ubuntu source show
that `tb_probe()` registers a PCI notifier embedded in the Thunderbolt
domain. Normal teardown unregisters it in `tb_deinit()`. If
`tb_domain_add()` fails, `nhi_probe()` calls `tb_domain_put()` without
unregistering the notifier. When the domain is freed, the PCI notifier
chain can retain a pointer into the freed allocation.

The probe timeout and Oops occurred in the same boot. The generic `-110`
message leaves open which function returned the timeout, so the exact
failing branch on this machine remains to be confirmed. The notifier was
introduced by the Ubuntu patch associated with LP #2155096
(https://bugs.launchpad.net/bugs/2155096).

I built a local module from the matching Ubuntu source with a change
that unregisters the native Thunderbolt PCI notifier and synchronously
cancels its queued display retry work before `tb_domain_put()` on the
failed `tb_domain_add()` path. The patched module compiled, loaded, and
completed its first boot. That boot did not log a Thunderbolt timeout.
Validation of the patched error path is pending.

** Affects: linux-hwe-7.0 (Ubuntu)
     Importance: Undecided
         Status: New

** Patch added: "Proposed fix: builds and boots locally. Timeout-path 
validation pending"
   
https://bugs.launchpad.net/bugs/2173712/+attachment/6016191/+files/pots-thunderbolt-probe-cleanup.patch

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2173712

Title:
  Thunderbolt probe timeout can leave a freed PCI notifier linked and
  cause a boot Oops at RIP 0

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-hwe-7.0/+bug/2173712/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to