OpenCloudOS-Kernel/arch/powerpc/platforms/pseries
Vaibhav Jain 07bf9431b1 powerpc/papr_scm: don't requests stats with '0' sized stats buffer
Sachin reported [1] that on a POWER-10 lpar he is seeing a kernel panic being
reported with vPMEM when papr_scm probe is being called. The panic is of the
form below and is observed only with following option disabled(profile) for the
said LPAR 'Enable Performance Information Collection' in the HMC:

 Kernel attempted to write user page (1c) - exploit attempt? (uid: 0)
 BUG: Kernel NULL pointer dereference on write at 0x0000001c
 Faulting instruction address: 0xc008000001b90844
 Oops: Kernel access of bad area, sig: 11 [#1]
<snip>
 NIP [c008000001b90844] drc_pmem_query_stats+0x5c/0x270 [papr_scm]
 LR [c008000001b92794] papr_scm_probe+0x2ac/0x6ec [papr_scm]
 Call Trace:
       0xc00000000941bca0 (unreliable)
       papr_scm_probe+0x2ac/0x6ec [papr_scm]
       platform_probe+0x98/0x150
       really_probe+0xfc/0x510
       __driver_probe_device+0x17c/0x230
<snip>
 ---[ end trace 0000000000000000 ]---
 Kernel panic - not syncing: Fatal exception

On investigation looks like this panic was caused due to a 'stat_buffer' of
size==0 being provided to drc_pmem_query_stats() to fetch all performance
stats-ids of an NVDIMM. However drc_pmem_query_stats() shouldn't have been called
since the vPMEM NVDIMM doesn't support and performance stat-id's. This was caused
due to missing check for 'p->stat_buffer_len' at the beginning of
papr_scm_pmu_check_events() which indicates that the NVDIMM doesn't support
performance-stats.

Fix this by introducing the check for 'p->stat_buffer_len' at the beginning of
papr_scm_pmu_check_events().

[1] https://lore.kernel.org/all/6B3A522A-6A5F-4CC9-B268-0C63AA6E07D3@linux.ibm.com

Fixes: 0e0946e22f ("powerpc/papr_scm: Fix leaking nvdimm_events_map elements")
Reported-by: Sachin Sant <sachinp@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Tested-by: Sachin Sant <sachinp@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220524112353.1718454-1-vaibhav@linux.ibm.com
2022-05-31 10:18:52 +10:00
..
Kconfig powerpc/pseries: Stop selecting PPC_HASH_MMU_NATIVE 2021-12-02 22:57:23 +11:00
Makefile powerpc: Book3S 64-bit outline-only KASAN support 2022-05-22 15:58:29 +10:00
cc_platform.c powerpc/pseries/svm: Add a powerpc version of cc_platform_has() 2021-10-04 11:46:33 +02:00
cmm.c powerpc/pseries/cmm: Remove unneeded variable "ret" 2022-05-04 19:37:43 +10:00
dlpar.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
dtl.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
eeh_pseries.c powerpc/eeh: Drop redundant spinlock initialization 2022-05-22 15:58:31 +10:00
event_sources.c powerpc/pseries: Add __init attribute to eligible functions 2021-12-23 22:33:15 +11:00
firmware.c powerpc/pseries: Interface to represent PAPR firmware attributes 2022-03-08 00:05:00 +11:00
hotplug-cpu.c powerpc/numa: Associate numa node to its cpu earlier 2022-05-22 15:58:30 +10:00
hotplug-memory.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
hvCall.S powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
hvCall_inst.c powerpc/pseries: Make symbol '__pcpu_scope_hcall_stats' static 2021-04-14 23:04:17 +10:00
hvconsole.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
hvcserver.c powerpc: Use fallthrough pseudo-keyword 2020-07-29 21:09:37 +10:00
ibmebus.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
io_event_irq.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
iommu.c Merge branch 'topic/ppc-kvm' into next 2022-05-19 23:10:42 +10:00
kexec.c powerpc/kasan: Disable address sanitization in kexec paths 2022-05-22 15:58:29 +10:00
lpar.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
lparcfg.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
mobility.c powerpc/pseries/vas: Add VAS migration handler 2022-03-08 00:04:56 +11:00
msi.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
nvram.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
of_helpers.c powerpc/pseries: Fix of_read_drc_info_cell() to point at next record 2020-03-25 12:06:43 +11:00
of_helpers.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
papr_platform_attributes.c powerpc/pseries: Interface to represent PAPR firmware attributes 2022-03-08 00:05:00 +11:00
papr_scm.c powerpc/papr_scm: don't requests stats with '0' sized stats buffer 2022-05-31 10:18:52 +10:00
pci.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
pci_dlpar.c powerpc/pseries: Fix use after free in remove_phb_dynamic() 2022-03-21 13:17:47 +11:00
pmem.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
power.c powerpc: declare unmodified attribute_group usages const 2022-03-08 22:15:32 +11:00
pseries.h powerpc/kasan: Disable address sanitization in kexec paths 2022-05-22 15:58:29 +10:00
pseries_energy.c powerpc/pseries: Fix drc-info mappings of logical cpus to drc-index 2019-11-13 16:57:57 +11:00
ras.c powerpc/mce: Avoid using irq_work_queue() in realmode 2022-03-08 00:05:00 +11:00
reconfig.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
rng.c powerpc/pseries: Fix missing of_node_put() in rng_init() 2020-08-25 01:31:31 +10:00
rtas-fadump.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
rtas-fadump.h powerpc/fadump: support holes in kernel boot memory area 2019-09-14 00:04:46 +10:00
setup.c powerpc updates for 5.19 2022-05-28 11:27:17 -07:00
smp.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
suspend.c powerpc/pseries/hibernation: remove prepare_late() callback 2020-12-08 21:41:02 +11:00
svm.c swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction 2022-04-18 07:21:12 +02:00
vas-sysfs.c powerpc/pseries/vas: Call misc_deregister if sysfs init fails 2022-05-22 15:58:31 +10:00
vas.c Merge branch 'fixes' into next 2022-05-19 00:11:51 +10:00
vas.h powerpc/pseries/vas: Use QoS credits from the userspace 2022-05-04 22:00:47 +10:00
vio.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
vphn.c powerpc/vphn: Check for error from hcall_vphn 2020-03-04 22:44:30 +11:00