linux/drivers/pci/hotplug
Niklas Schnelle a46044a92a s390/pci: fix zpci_zdev_put() on reserve
Since commit 2a671f77ee ("s390/pci: fix use after free of zpci_dev")
the reference count of a zpci_dev is incremented between
pcibios_add_device() and pcibios_release_device() which was supposed to
prevent the zpci_dev from being freed while the common PCI code has
access to it. It was missed however that the handling of zPCI
availability events assumed that once zpci_zdev_put() was called no
later availability event would still see the device. With the previously
mentioned commit however this assumption no longer holds and we must
make sure that we only drop the initial long-lived reference the zPCI
subsystem holds exactly once.

Do so by introducing a zpci_device_reserved() function that handles when
a device is reserved. Here we make sure the zpci_dev will not be
considered for further events by removing it from the zpci_list.

This also means that the device actually stays in the
ZPCI_FN_STATE_RESERVED state between the time we know it has been
reserved and the final reference going away. We thus need to consider it
a real state instead of just a conceptual state after the removal. The
final cleanup of PCI resources, removal from zbus, and destruction of
the IOMMU stays in zpci_release_device() to make sure holders of the
reference do see valid data until the release.

Fixes: 2a671f77ee ("s390/pci: fix use after free of zpci_dev")
Cc: stable@vger.kernel.org
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2021-10-04 09:49:10 +02:00
..
acpi_pcihp.c PCI: Fix kernel-doc errors 2021-03-11 17:37:20 -06:00
acpiphp_core.c
acpiphp_glue.c ACPI / hotplug / PCI: Fix reference count leak in enable_slot() 2021-04-08 11:04:18 -05:00
acpiphp_ibm.c
acpiphp.h PCI: acpiphp: Fix whitespace issue 2021-04-16 14:32:18 -05:00
cpci_hotplug_core.c
cpci_hotplug_pci.c PCI: cpcihp: Declare cpci_debug in header file 2021-07-01 15:32:45 -05:00
cpci_hotplug.h PCI: cpcihp: Declare cpci_debug in header file 2021-07-01 15:32:45 -05:00
cpcihp_generic.c
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp_core.c PCI: Fix kernel-doc formatting 2021-07-06 10:37:46 -05:00
cpqphp_ctrl.c PCI: Fix kernel-doc formatting 2021-07-06 10:37:46 -05:00
cpqphp_nvram.c PCI: cpqphp: Use DEFINE_SPINLOCK() for int15_lock 2021-04-14 15:24:10 -05:00
cpqphp_nvram.h
cpqphp_pci.c
cpqphp_sysfs.c
cpqphp.h
ibmphp_core.c
ibmphp_ebda.c PCI: ibmphp: Fix double unmap of io_mem 2021-09-02 12:02:50 -05:00
ibmphp_hpc.c
ibmphp_pci.c PCI: ibmphp: Remove unneeded break 2020-11-20 11:17:55 -06:00
ibmphp_res.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ibmphp.h
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile
pci_hotplug_core.c PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions 2021-06-03 22:14:47 -05:00
pciehp_core.c PCI: Fix kerneldoc warnings 2020-08-05 18:23:14 -05:00
pciehp_ctrl.c pci-v5.10-changes 2020-10-22 12:41:00 -07:00
pciehp_hpc.c PCI: Change the type of probe argument in reset functions 2021-08-18 17:32:42 -05:00
pciehp_pci.c
pciehp.h PCI: Change the type of probe argument in reset functions 2021-08-18 17:32:42 -05:00
pnv_php.c PCI: Change the type of probe argument in reset functions 2021-08-18 17:32:42 -05:00
rpadlpar_core.c PCI: rpadlpar: Use for_each_child_of_node() and for_each_node_by_name() 2020-09-17 16:22:36 -05:00
rpadlpar_sysfs.c PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions 2021-06-03 22:14:47 -05:00
rpadlpar.h
rpaphp_core.c PCI: Use of_node_name_eq() for node name comparisons 2020-04-24 18:02:17 -05:00
rpaphp_pci.c powerpc/eeh: Make early EEH init pseries specific 2020-03-25 12:09:39 +11:00
rpaphp_slot.c
rpaphp.h
s390_pci_hpc.c s390/pci: fix zpci_zdev_put() on reserve 2021-10-04 09:49:10 +02:00
shpchp_core.c
shpchp_ctrl.c pci-v5.10-changes 2020-10-22 12:41:00 -07:00
shpchp_hpc.c PCI: shpchp: Remove unused shpc_writeb() 2021-04-16 11:22:24 -05:00
shpchp_pci.c PCI: shpchp: Make shpchp_unconfigure_device() void 2020-05-21 15:23:20 -05:00
shpchp_sysfs.c PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions 2021-06-03 22:14:47 -05:00
shpchp.h PCI: shpchp: Make shpchp_unconfigure_device() void 2020-05-21 15:23:20 -05:00
TODO PCI: ibmphp: Fix double unmap of io_mem 2021-09-02 12:02:50 -05:00