CVE-2026-142976: w1: remove the master's files before taking its locks
In the Linux kernel, the following vulnerability has been resolved:
w1: remove the master's files before taking its locks
w1removemasterdevice() calls w1destroymasterattributes() with both the mutex of the master and listmutex held. Removing the files waits for the callbacks which are running, and nearly all of them take one of these two locks:
w1removemasterdevice() read() of .../w1masterslaves mutexlock(&dev->mutex) kernfs active reference mutexlock(&dev->listmutex) w1masterattributeshowslaves() w1destroymasterattributes() mutexlock(&md->listmutex) sysfsremovegroup() waits waits for the reference
The files are readable for everybody, and a bus master goes away when, for instance, a DS2490 USB adapter is unplugged.
Remove the files first, before the locks are taken. That has to be done before the slaves are detached and not afterwards: as long as the files exist, a write to w1masteradd could attach a new slave behind the back of this function, which would then wait for the reference count of the master for ever. And it is done before the thread is stopped, because a write to w1mastersearch wakes the thread up.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In __w1_remove_master_device(), remove the master's files with w1_destroy_master_attributes() before taking the master and list locks.
Event History
Frequently Asked Questions
Which systems are exposed to this issue?
Systems using the Linux kernel w1 subsystem with a bus master that can be removed are exposed during master-device removal. The description specifically identifies unplugging a DS2490 USB adapter as an example trigger.
What activity can cause the removal path to stall?
The issue occurs when master attributes are removed while the master's mutex and list_mutex are held. Removing the sysfs files waits for active callbacks, while callbacks such as reads of w1_master_slaves can attempt to acquire those same locks.
Can concurrent sysfs access make the condition more likely?
Yes. The affected files are readable by all users, and reads can hold an active kernfs reference while waiting on the master's locks. Writes to w1_master_add can also attach a slave during teardown if the files remain available, and writes to w1_master_search can wake the master thread.