OpenCloudOS-Kernel/arch/powerpc/platforms
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
..
4xx powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
8xx powerpc/8xx: Use kmalloced data structure instead of global static 2022-05-11 23:06:40 +10:00
40x powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
44x powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
52xx powerpc: Fix all occurences of "the the" 2022-05-22 15:59:43 +10:00
82xx powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
83xx powerpc/platforms/83xx: Use of_device_get_match_data() 2022-05-22 15:58:31 +10:00
85xx powerpc/85xx: Remove FSL_85XX_CACHE_SRAM 2022-05-22 15:58:30 +10:00
86xx powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
512x powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
amigaone powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
book3s powerpc: fix typos in comments 2022-05-05 22:12:44 +10:00
cell powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
chrp powerpc: Fix all occurences of "the the" 2022-05-22 15:59:43 +10:00
embedded6xx powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
maple powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
microwatt powerpc/microwatt: add POWER9_CPU, clear PPC_64S_HASH_MMU 2021-12-09 22:41:16 +11:00
pasemi powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
powermac powerpc/powermac: constify device_node in of_irq_parse_oldworld() 2022-05-22 15:59:54 +10:00
powernv powerpc/kasan: Mark more real-mode code as not to be instrumented 2022-05-29 10:30:42 +10:00
ps3 powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
pseries powerpc/papr_scm: don't requests stats with '0' sized stats buffer 2022-05-31 10:18:52 +10:00
Kconfig powerpc: Rename PPC_NATIVE to PPC_HASH_MMU_NATIVE 2021-12-02 22:57:22 +11:00
Kconfig.cputype powerpc: Book3S 64-bit outline-only KASAN support 2022-05-22 15:58:29 +10:00
Makefile powerpc: Add Microwatt platform 2021-06-21 21:15:26 +10:00
fsl_uli1575.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00