freenode
Kernel & Low-Level

Driver core deadlock freezes probe on sysfs read since 5.9

A world-readable waiting_for_supplier attribute can permanently hang both the reader and device probe on success.

A deadlock in the Linux driver core can permanently hang a device probe and any process that reads a related sysfs attribute at the wrong moment. Kernels since 5.9 are affected.

Firmware device link support, enabled by default, creates a world-readable waiting_for_supplier attribute for every device that has a firmware node and is not yet bound. The attribute is meant to show whether the device is still waiting on suppliers. Reading it takes the device lock while the reader holds an active reference on the sysfs file. On a successful probe the kernel removes that file while still holding the same lock and waits for the reference to drop. The reader therefore waits for the prober, and the prober waits for the reader. Neither side ever wakes. Lockdep does not report the cycle.

Because the file is world-readable, ordinary activity during module load or deferred probe (udev, a tool walking /sys, or a plain cat) is enough to trigger it. The probing task keeps the device lock, so later work that needs the same lock, including shutdown, stalls as well.

Nickolai Zeldovich reported the bug and submitted a fix that simply drops the device lock from the attribute read path. The value is already computed under the firmware-node link lock held by every writer of the supplier list, and the sysfs active reference already prevents the device from disappearing while the read runs. He reproduced the hang under QEMU with a SCSI host module whose probe includes a multi-second bus settle delay: a concurrent read of the PCI device attribute left both insmod and the reader stuck until the change, after which the read returned and the module load finished.