linux/drivers/pci
Thomas Gleixner 0b2c2a71e6 PCI: Replace the racy recursion prevention
pci_call_probe() can called recursively when a physcial function is probed
and the probing creates virtual functions, which are populated via
pci_bus_add_device() which in turn can end up calling pci_call_probe()
again.

The code has an interesting way to prevent recursing into the workqueue
code.  That's accomplished by a check whether the current task runs already
on the numa node which is associated with the device.

While that works to prevent the recursion into the workqueue code, it's
racy versus normal execution as there is no guarantee that the node does
not vanish after the check.

There is another issue with this code. It dereferences cpumask_of_node()
unconditionally without checking whether the node is available.

Make the detection reliable by:

 - Mark a probed device as 'is_probed' in pci_call_probe()
 
 - Check in pci_call_probe for a virtual function. If it's a virtual
   function and the associated physical function device is marked
   'is_probed' then this is a recursive call, so the call can be invoked in
   the calling context.

 - Add a check whether the node is online before dereferencing it.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-pci@vger.kernel.org
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170524081548.771457199@linutronix.de
2017-05-26 10:10:43 +02:00
..
dwc pci-v4.12-changes 2017-05-08 19:03:25 -07:00
endpoint PCI: endpoint: functions: Add an EP function to test PCI 2017-04-11 14:18:37 -05:00
host PCI: Don't allow unbinding host controllers that aren't prepared 2017-04-28 10:38:00 -05:00
hotplug Annotation of module parameters that specify device settings 2017-05-10 19:13:03 -07:00
pcie Merge branch 'pci/enumeration' into next 2017-04-28 10:33:55 -05:00
switch switchtec: Add IOCTLs to the Switchtec driver 2017-04-12 12:23:37 -05:00
access.c Merge branch 'pci/misc' into next 2017-04-28 10:34:14 -05:00
ats.c
bus.c PCI: Autosense device removal in pci_bridge_d3_update() 2016-11-17 18:44:56 -06:00
ecam.c PCI: ECAM: Map config region with pci_remap_cfgspace() 2017-04-24 13:53:14 -05:00
host-bridge.c cxl: use pcibios_free_controller_deferred() when removing vPHBs 2016-08-22 11:09:33 +10:00
hotplug-pci.c
htirq.c
iov.c PCI: Add sysfs sriov_drivers_autoprobe to control VF driver binding 2017-04-20 08:53:51 -05:00
irq.c pci-v4.12-changes 2017-05-08 19:03:25 -07:00
Kconfig Merge branch 'pci/switchtec' into next 2017-04-28 10:33:41 -05:00
Makefile Merge branch 'pci/resource-mmap' into next 2017-04-28 10:34:34 -05:00
mmap.c PCI: Add I/O BAR support to generic pci_mmap_resource_range() 2017-04-20 08:47:47 -05:00
msi.c pci-v4.12-changes 2017-05-08 19:03:25 -07:00
of.c PCI/MSI: Use of_msi_get_domain instead of open-coded "msi-parent" parsing 2015-10-16 13:07:14 +01:00
pci-acpi.c Merge branch 'pci/pm' into next 2016-12-12 11:25:04 -06:00
pci-driver.c PCI: Replace the racy recursion prevention 2017-05-26 10:10:43 +02:00
pci-label.c PCI: Fix broken URL for Dell biosdevname 2016-02-29 12:03:19 -06:00
pci-mid.c pci-v4.10-changes 2016-12-15 12:46:48 -08:00
pci-stub.c
pci-sysfs.c Merge branch 'pci/virtualization' into next 2017-04-28 10:36:12 -05:00
pci.c Merge branch 'pci/virtualization' into next 2017-04-28 10:36:12 -05:00
pci.h pci-v4.12-changes 2017-05-08 19:03:25 -07:00
probe.c IOMMU Updates for Linux v4.12 2017-05-09 15:15:47 -07:00
proc.c PCI: Add BAR index argument to pci_mmap_page_range() 2017-04-20 08:47:47 -05:00
quirks.c Merge branch 'pci/virtualization' into next 2017-04-28 10:36:12 -05:00
remove.c PCI: Autosense device removal in pci_bridge_d3_update() 2016-11-17 18:44:56 -06:00
rom.c PCI: Add comments about ROM BAR updating 2016-11-29 18:05:09 -06:00
search.c PCI: Add device flag PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT 2017-04-13 18:49:50 -05:00
setup-bus.c PCI: Fix calculation of bridge window's size and alignment 2017-04-18 14:47:20 -05:00
setup-irq.c
setup-res.c PCI: Make PCI_ROM_ADDRESS_MASK a 32-bit constant 2017-04-18 14:46:57 -05:00
slot.c locking/atomic, kref: Add kref_read() 2017-01-14 11:37:18 +01:00
syscall.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
vc.c PCI: Fix unaligned accesses in VC code 2016-06-20 13:24:20 -05:00
vpd.c
xen-pcifront.c xen: make use of xenbus_read_unsigned() in xen-pcifront 2016-11-07 13:55:26 +01:00