linux/arch/powerpc/platforms/powernv
Vasant Hegde 0a43ae3e2b powerpc/powernv/dump: Fix race while processing OPAL dump
Every dump reported by OPAL is exported to userspace through a sysfs
interface and notified using kobject_uevent(). The userspace daemon
(opal_errd) then reads the dump and acknowledges that the dump is
saved safely to disk. Once acknowledged the kernel removes the
respective sysfs file entry causing respective resources to be
released including kobject.

However it's possible the userspace daemon may already be scanning
dump entries when a new sysfs dump entry is created by the kernel.
User daemon may read this new entry and ack it even before kernel can
notify userspace about it through kobject_uevent() call. If that
happens then we have a potential race between
dump_ack_store->kobject_put() and kobject_uevent which can lead to
use-after-free of a kernfs object resulting in a kernel crash.

This patch fixes this race by protecting the sysfs file
creation/notification by holding a reference count on kobject until we
safely send kobject_uevent().

The function create_dump_obj() returns the dump object which if used
by caller function will end up in use-after-free problem again.
However, the return value of create_dump_obj() function isn't being
used today and there is no need as well. Hence change it to return
void to make this fix complete.

Fixes: c7e64b9ce0 ("powerpc/powernv Platform dump interface")
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201017164210.264619-1-hegdevasant@linux.vnet.ibm.com
2020-10-19 22:52:08 +11:00
..
copy-paste.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
eeh-powernv.c powerpc/eeh: Clean up PE addressing 2020-10-06 23:22:25 +11:00
idle.c powerpc/powernv/idle: add a basic stop 0-3 driver for POWER10 2020-09-15 22:13:38 +10:00
Kconfig powerpc/powernv: Move SCOM access code into powernv platform 2019-08-05 18:53:03 +10:00
Makefile powerpc/powernv/sriov: Move SR-IOV into a separate file 2020-07-26 23:34:22 +10:00
memtrace.c powernv/memtrace: always online added memory blocks 2020-04-07 10:43:40 -07:00
npu-dma.c powerpc/powernv/npu: Move IOMMU group setup into npu-dma.c 2020-05-28 23:24:38 +10:00
ocxl.c ocxl: Remove custom service to allocate interrupts 2020-08-25 01:31:31 +10:00
opal-async.c powerpc: Use fallthrough pseudo-keyword 2020-07-29 21:09:37 +10:00
opal-call.c powerpc/powernv: Add OPAL API interface to access secure variable 2019-11-13 00:33:22 +11:00
opal-core.c powerpc/powernv: fix wrong warning message in opalcore_config_init() 2020-09-18 19:59:45 +10:00
opal-dump.c powerpc/powernv/dump: Fix race while processing OPAL dump 2020-10-19 22:52:08 +11:00
opal-elog.c powerpc/opal_elog: Handle multiple writes to ack attribute 2020-10-16 14:25:12 +11:00
opal-fadump.c powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() 2020-05-11 23:15:15 +10:00
opal-fadump.h powerpc/fadump: support holes in kernel boot memory area 2019-09-14 00:04:46 +10:00
opal-flash.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-hmi.c powerpc/powernv: Show checkstop reason for NPU2 HMIs 2019-06-02 19:39:36 +10:00
opal-imc.c powerpc/powernv: Re-enable imc trace-mode in kernel 2020-04-03 00:09:58 +11:00
opal-irqchip.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-kmsg.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-lpc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-memory-errors.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
opal-msglog.c powerpc/powernv: Include asm/powernv.h from the local powernv.h 2020-08-25 01:31:33 +10:00
opal-nvram.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-power.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-powercap.c powerpc/powernv: Make some symbols static 2019-11-13 16:58:06 +11:00
opal-prd.c powerpc/powernv: Fix spurious kerneldoc warnings in opal-prd.c 2020-08-25 01:31:33 +10:00
opal-psr.c powerpc/powernv: Make some symbols static 2019-11-13 16:58:06 +11:00
opal-rtc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-secvar.c powerpc/powernv: Add OPAL API interface to access secure variable 2019-11-13 00:33:22 +11:00
opal-sensor-groups.c powerpc/powernv: Make some symbols static 2019-11-13 16:58:06 +11:00
opal-sensor.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
opal-sysparam.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
opal-tracepoints.c jump_label: move 'asm goto' support test to Kconfig 2019-01-06 09:46:51 +09:00
opal-wrappers.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
opal-xscom.c powerpc/powernv: Fix checkpatch warnings in opal-xscom.c 2019-08-05 18:53:03 +10:00
opal.c powerpc/powernv: add NULL check after kzalloc 2020-05-20 23:39:56 +10:00
pci-cxl.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
pci-ioda-tce.c powerpc/powernv/ioda: Return correct error if TCE level allocation failed 2020-06-22 10:37:59 +10:00
pci-ioda.c powerpc/powernv: Remove set but not used variable 'parent' 2020-08-25 01:31:32 +10:00
pci-sriov.c powerpc/powernv/sriov: Fix use of uninitialised variable 2020-08-03 22:13:13 +10:00
pci.c powerpc/powernv/pci: Add pci_bus_to_pnvhb() helper 2020-07-26 23:34:21 +10:00
pci.h powerpc/powernv/pci.h: delete duplicated word 2020-07-27 00:01:32 +10:00
powernv.h powerpc/powernv: Include asm/powernv.h from the local powernv.h 2020-08-25 01:31:33 +10:00
rng.c powerpc/powernv: Staticify functions without prototypes 2020-08-25 01:31:33 +10:00
setup.c powerpc/powernv: Print helpful message when cores guarded 2020-09-08 22:57:11 +10:00
smp.c powerpc/smp: Move ppc_md.cpu_die() to smp_ops.cpu_offline_self() 2020-09-18 19:59:43 +10:00
subcore-asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
subcore.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
subcore.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ultravisor.c powerpc/powernv: Add ultravisor message log interface 2019-08-30 09:40:16 +10:00
vas-api.c powerpc/vas: Add VAS user space API 2020-04-20 16:53:14 +10:00
vas-debug.c powerpc/vas: Take reference to PID and mm for user space windows 2020-04-20 16:53:00 +10:00
vas-fault.c powerpc/vas: Report proper error code for address translation failure 2020-07-15 23:09:55 +10:00
vas-trace.h powerpc/vas: Add a couple of trace points 2018-03-14 20:13:58 +11:00
vas-window.c powerpc/powernv: Staticify functions without prototypes 2020-08-25 01:31:33 +10:00
vas.c powerpc/vas: Setup thread IRQ handler per VAS instance 2020-04-20 16:53:00 +10:00
vas.h powerpc/vas: Add VAS user space API 2020-04-20 16:53:14 +10:00