blob: 53ac223948acd5cb3649d0135fef303962b7c5f6 [file] [log] [blame]
The Linux kernel is vulnerable to a deadlock when adding SPI controllers on SPI buses. The issue arises from the use of a global `spi_add_lock` which is taken when adding new devices to ensure that chip selects are not reused. However, if an SPI device is itself a SPI controller and triggers the instantiation of further SPI devices, it can cause a deadlock.
The deadlock occurs because the registration and instantiation of the child devices happen while holding the global `spi_add_lock`, which is already held by the parent controller. To fix this issue, the lock has been moved to be per-controller, avoiding the deadlock. This vulnerability can be easily triggered in cases where an SPI device is a mux (a multiplexer that selects one of several input signals).
The fix involves moving the `spi_add_lock` from being a global lock to a per-controller lock, allowing multiple controllers on the same bus to add devices concurrently without deadlocking. The fix has been applied in kernel versions 5.14.15 and 5.15, with commits 722ef19a161c and 6098475d4cb4, respectively.