PCI: Avoid pci_dev_lock() AB/BA deadlock with sriov_numvfs_store()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 17530e71e0166a37f8e20a9b7bcf1d50ae3cff8e · < ea047f51172aa68841adef7f52d375002438b8f0| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
PCI: Avoid pci_dev_lock() AB/BA deadlock with sriov_numvfs_store()
The sysfs sriov_numvfs_store() path acquires the device lock before the config space access lock:
sriov_numvfs_store device_lock # A (1) acquire device lock sriov_configure vfio_pci_sriov_configure # (for example) vfio_pci_core_sriov_configure pci_disable_sriov sriov_disable pci_cfg_access_lock pci_wait_cfg # B (4) wait for dev->block_cfg_access == 0
Previously, pci_dev_lock() acquired the config space access lock before the device lock:
pci_dev_lock pci_cfg_access_lock dev->block_cfg_access = 1 # B (2) set dev->block_cfg_access = 1 device_lock # A (3) wait for device lock
Any path that uses pci_dev_lock(), e.g., pci_reset_function(), may deadlock with sriov_numvfs_store() if the operations occur in the sequence (1) (2) (3) (4).
Avoid the deadlock by reversing the order in pci_dev_lock() so it acquires the device lock before the config space access lock, the same as the sriov_numvfs_store() path.
From the CVE record · Linux
The Linux kernel can deadlock when pci_dev_lock() and sriov_numvfs_store() acquire device and PCI configuration-space locks in opposite orders. Concurrent operations through these paths, such as a PCI function reset and an SR-IOV configuration change, can trigger the deadlock. The input does not specify attacker access or authentication requirements.
Engineers running Linux kernels with the affected PCI locking paths should check their kernel versions; affected versions are not specified.