linux_dsm_epyc7002/arch
Niklas Schnelle e115d2997b s390/pci: fix use after free of zpci_dev
[ Upstream commit 2a671f77ee49f3e78997b77fdee139467ff6a598 ]

The struct pci_dev uses reference counting but zPCI assumed erroneously
that the last reference would always be the local reference after
calling pci_stop_and_remove_bus_device(). This is usually the case but
not how reference counting works and thus inherently fragile.

In fact one case where this causes a NULL pointer dereference when on an
SRIOV device the function 0 was hot unplugged before another function of
the same multi-function device. In this case the second function's
pdev->sriov->dev reference keeps the struct pci_dev of function 0 alive
even after the unplug. This bug was previously hidden by the fact that
we were leaking the struct pci_dev which in turn means that it always
outlived the struct zpci_dev. This was fixed in commit 0b13525c20fe
("s390/pci: fix leak of PCI device structure") exposing the broken
behavior.

Fix this by accounting for the long living reference a struct pci_dev
has to its underlying struct zpci_dev via the zbus->function[] array and
only release that in pcibios_release_device() ensuring that the struct
pci_dev is not left with a dangling reference. This is a minimal fix in
the future it would probably better to use fine grained reference
counting for struct zpci_dev.

Fixes: 05bc1be6db ("s390/pci: create zPCI bus")
Cc: stable@vger.kernel.org
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-05 18:55:59 +02:00
..
alpha alpha: Send stop IPI to send to online CPUs 2024-07-05 18:52:32 +02:00
arc ARC: fp: set FPU_STATUS.FWE to enable FPU_STATUS update on context switch 2024-07-05 18:53:59 +02:00
arm ARM: dts: nomadik: Fix up interrupt controller node names 2024-07-05 18:55:44 +02:00
arm64 arm64: dts: qcom: msm8992-bullhead: Remove PSCI 2024-07-05 18:55:45 +02:00
c6x arch-cleanup-2020-10-22 2020-10-23 10:06:38 -07:00
csky csky: syscache: Fixup duplicate cache flush 2021-07-14 16:56:52 +02:00
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-02-17 11:02:28 +01:00
hexagon hexagon: use common DISCARDS macro 2021-07-20 16:05:53 +02:00
ia64 mm/page_alloc: fix memory map initialization for descending nodes 2021-07-25 14:36:18 +02:00
m68k m68k: atari: Fix ATARI_KBD_CORE kconfig unmet dependency warning 2021-07-14 16:56:05 +02:00
microblaze init: add dsm gpl source 2024-07-05 18:00:04 +02:00
mips MIPS: Malta: Do not byte-swap accesses to the CBUS UART 2024-07-05 18:52:29 +02:00
nds32 nds32: fix up stack guard gap 2021-07-28 14:35:46 +02:00
nios2 nios2: fixed broken sys_clone syscall 2021-03-04 11:38:16 +01:00
openrisc sched/core: Initialize the idle task with preemption disabled 2021-07-14 16:55:50 +02:00
parisc sched/core: Initialize the idle task with preemption disabled 2021-07-14 16:55:50 +02:00
powerpc powerpc/smp: Fix OOPS in topology_init() 2024-07-05 18:54:41 +02:00
riscv init: add dsm gpl source 2024-07-05 18:00:04 +02:00
s390 s390/pci: fix use after free of zpci_dev 2024-07-05 18:55:59 +02:00
sh sched/core: Initialize the idle task with preemption disabled 2021-07-14 16:55:50 +02:00
sparc init: add dsm gpl source 2024-07-05 18:00:04 +02:00
um um: fix error return code in winch_tramp() 2021-07-20 16:05:51 +02:00
x86 KVM: X86: Fix warning caused by stale emulation context 2024-07-05 18:55:30 +02:00
xtensa init: add dsm gpl source 2024-07-05 18:00:04 +02:00
.gitignore
Kconfig fanotify: Fix sys_fanotify_mark() on native x86-32 2021-01-17 14:16:59 +01:00