linux-stable/arch
Vasant Hegde b398d1dcf3 powerpc/powernv/dump: Fix race while processing OPAL dump
[ Upstream commit 0a43ae3e2b ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29 09:07:13 +01:00
..
alpha alpha: fix annotation of io{read,write}{16,32}be() 2020-08-26 10:29:57 +02:00
arc arc: plat-hsdk: fix kconfig dependency warning when !RESET_CONTROLLER 2020-10-29 09:07:09 +01:00
arm ARM: dts: owl-s500: Fix incorrect PPI interrupt specifiers 2020-10-29 09:07:13 +01:00
arm64 arm64: dts: zynqmp: Remove additional compatible string for i2c IPs 2020-10-29 09:07:13 +01:00
blackfin
c6x
cris
frv
h8300
hexagon hexagon: work around compiler crash 2020-01-17 19:45:55 +01:00
ia64
m32r
m68k m68k: q40: Fix info-leak in rtc_ioctl 2020-10-01 13:12:26 +02:00
metag
microblaze microblaze: Prevent the overflow of the start 2020-02-28 16:36:08 +01:00
mips MIPS: Add the missing 'CPU_1074K' into __get_cpu_type() 2020-10-01 13:12:51 +02:00
mn10300
nios2 nios2: ksyms: Add missing symbol exports 2020-01-27 14:46:24 +01:00
openrisc openrisc: Fix issue with argument clobbering for clone/fork 2020-06-25 15:41:56 +02:00
parisc parisc: Implement __smp_store_release and __smp_load_acquire barriers 2020-08-21 09:48:16 +02:00
powerpc powerpc/powernv/dump: Fix race while processing OPAL dump 2020-10-29 09:07:13 +01:00
s390 s390/init: add missing __init annotations 2020-10-01 13:12:48 +02:00
score
sh sh: landisk: Add missing initialization of sh_io_port_base 2020-08-21 09:48:23 +02:00
sparc fix a braino in "sparc32: fix register window handling in genregs32_[gs]et()" 2020-06-30 15:37:57 -04:00
tile
um um: Make GCOV depend on !KCOV 2019-12-05 15:37:49 +01:00
unicore32
x86 KVM: x86: emulating RDPID failure shall return #UD rather than #GP 2020-10-29 09:07:13 +01:00
xtensa block: Move SECTOR_SIZE and SECTOR_SHIFT definitions into <linux/blkdev.h> 2020-09-09 19:03:12 +02:00
.gitignore
Kconfig