CVE-2026-142950: nvme: fix deadlock on nvme_subsystems_lock in nvme_init_subsystem()
In the Linux kernel, the following vulnerability has been resolved:
nvme: fix deadlock on nvmesubsystemslock in nvmeinitsubsystem()
Connecting a controller to a new subsystem deadlocks when sysfscreatelink() fails in nvmeinitsubsystem(), e.g., on an allocation failure. The error path drops the last subsystem reference with nvmesubsystemslock held and nvmedestroysubsystem() takes the same lock again:
nvme nvme0: failed to create sysfs link from subsystem. ============================================ WARNING: possible recursive locking detected ... nvmesubsys/95 is trying to acquire lock: (nvmesubsystemslock){+.+.}-{4:4}, at: nvmedestroysubsystem+0x1b/0x1e0
but task is already holding lock: (nvmesubsystemslock){+.+.}-{4:4}, at: nvmeinitidentify+0x81e/0x34b0 ... Call Trace: mutexlock+0x1a2/0x26e0 nvmedestroysubsystem+0x1b/0x1e0 nvmeinitidentify.cold+0x3bc/0x56f nvmeinitctrlfinish+0x1bc/0x7a0 nvmeloopconfigureadminqueue+0x205/0x2b0 nvmeloopcreatectrl+0x480/0xd10 nvmfdevwrite+0x365/0x650 vfswrite+0x1e3/0x1250 ksyswrite+0xfa/0x200 dosyscall64+0xfb/0x590 entrySYSCALL64afterhwframe+0x77/0x7f ... INFO: task nvmesubsys:95 blocked for more than 20 seconds. INFO: task nvmesubsys:95 is blocked on a mutex likely owned by task nvmesubsys:95.
Every later controller setup or removal then waits for the lock too. The nvmevalidatecntlid() error path for an existing subsystem does the same put, and deadlocks the same way if the other references go away in between.
Drop the lock before the put. For a new subsystem, take it off the list first so another controller can't find it in between. With the fix, the connect fails and the next connect works.
This bug was identified and confirmed with the help of a deterministic hypervisor currently under development. The C reproducer below however hits it within about 30s.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In nvme_init_subsystem(), drop nvme_subsystems_lock before the final subsystem put; for a new subsystem, remove it from the list before dropping the lock so another controller cannot find it in between.
Event History
Frequently Asked Questions
What systems are realistically exposed to this deadlock?
Systems using the Linux NVMe subsystem are exposed when connecting a controller to a new subsystem. The reported trigger is a failure creating the subsystem sysfs link during initialization.
What must occur for the deadlock to be triggered?
sysfs_create_link() must fail in nvme_init_subsystem(), with allocation failure given as an example. The resulting error path releases the final subsystem reference while nvme_subsystems_lock is held, then attempts to acquire that same lock again during subsystem destruction.
How would an affected system present?
Kernel logging may report failure to create the subsystem sysfs link, a possible recursive locking warning involving nvme_subsystems_lock, and an nvmesubsys task blocked for an extended period. The provided trace shows this occurring while configuring an NVMe loop controller through nvmf_dev_write.