Skip to content

Commit 479380e

Browse files
Nishanth Aravamudanbjorn-helgaas
authored andcommitted
PCI: Avoid reset when disabled via sysfs
After d88f521 ("PCI: Allow userspace to query and set device reset mechanism"), userspace can disable reset of specific PCI devices by writing an empty string to the sysfs reset_method file. However, pci_slot_resettable() does not check pci_reset_supported(), which means that pci_reset_function() will still reset the device even if userspace has disabled all the reset methods. I was able to reproduce this issue with a vfio device passed to a qemu guest, where I had disabled PCI reset via sysfs. Add an explicit check of pci_reset_supported() in both pci_slot_resettable() and pci_bus_resettable() to ensure both the reset status and reset execution are bypassed if an administrator disables it for a device. Link: https://lore.kernel.org/r/[email protected] Fixes: d88f521 ("PCI: Allow userspace to query and set device reset mechanism") Signed-off-by: Nishanth Aravamudan <[email protected]> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Raphael Norwitz <[email protected]> Cc: Amey Narkhede <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Yishai Hadas <[email protected]> Cc: Shameer Kolothum <[email protected]> Cc: Kevin Tian <[email protected]>
1 parent 800ce27 commit 479380e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/pci/pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5410,6 +5410,8 @@ static bool pci_bus_resettable(struct pci_bus *bus)
54105410
return false;
54115411

54125412
list_for_each_entry(dev, &bus->devices, bus_list) {
5413+
if (!pci_reset_supported(dev))
5414+
return false;
54135415
if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
54145416
(dev->subordinate && !pci_bus_resettable(dev->subordinate)))
54155417
return false;
@@ -5486,6 +5488,8 @@ static bool pci_slot_resettable(struct pci_slot *slot)
54865488
list_for_each_entry(dev, &slot->bus->devices, bus_list) {
54875489
if (!dev->slot || dev->slot != slot)
54885490
continue;
5491+
if (!pci_reset_supported(dev))
5492+
return false;
54895493
if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
54905494
(dev->subordinate && !pci_bus_resettable(dev->subordinate)))
54915495
return false;

0 commit comments

Comments
 (0)