linux/arch/powerpc
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
..
boot powerpc: Remove support for PowerPC 601 2020-10-08 21:17:13 +11:00
configs powerpc: switch 85xx defconfigs from legacy ide to libata 2020-10-06 23:22:24 +11:00
crypto powerpc: Replace HTTP links with HTTPS ones 2020-07-22 00:01:23 +10:00
include Revert "powerpc/pci: unmap legacy INTx interrupts when a PHB is removed" 2020-10-15 13:42:49 +11:00
kernel powerpc/smp: Use GFP_ATOMIC while allocating tmp mask 2020-10-19 21:32:34 +11:00
kexec powerpc/kexec_file: Enable early kernel OPAL calls 2020-07-29 23:47:55 +10:00
kvm powerpc/64s: handle ISA v3.1 local copy-paste context switches 2020-09-08 22:57:12 +10:00
lib powerpc/sstep: Remove empty if statement checking for invalid form 2020-09-18 20:05:24 +10:00
math-emu
mm powerpc/32s: Setup the early hash table at all time. 2020-10-08 21:17:14 +11:00
net powerpc/ppc-opcode: Consolidate powerpc instructions from bpf_jit.h 2020-07-16 13:12:42 +10:00
oprofile powerpc/oprofile: fix spelling mistake "contex" -> "context" 2020-08-25 01:31:33 +10:00
perf powerpc/hv-gpci: Add sysfs files inside hv-gpci device to show cpumask 2020-10-07 22:34:49 +11:00
platforms powerpc/powernv/dump: Fix race while processing OPAL dump 2020-10-19 22:52:08 +11:00
purgatory powerpc/kexec_file: Enable early kernel OPAL calls 2020-07-29 23:47:55 +10:00
sysdev powerpc/xive: Make debug routines static 2020-09-18 20:05:25 +10:00
tools powerpc/tools: Remove 90 line limit in checkpatch script 2020-09-08 22:57:11 +10:00
xmon powerpc/watchpoint: Add hw_len wherever missing 2020-09-15 22:13:20 +10:00
Kbuild powerpc/kexec: Move kexec files into a dedicated subdir. 2019-11-21 15:41:34 +11:00
Kconfig powerpc/rtas: Restrict RTAS requests from userspace 2020-10-06 23:22:27 +11:00
Kconfig.debug powerpc: Remove Xilinx PPC405/PPC440 support 2020-05-28 23:24:34 +10:00
Makefile powerpc/32s: Rename head_32.S to head_book3s_32.S 2020-10-08 21:17:14 +11:00
Makefile.postlink powerpc: unrel_branch_check.sh: use nm to find symbol value 2020-09-02 11:00:22 +10:00