Skip to content

Commit 429d94c

Browse files
author
Mamatha Inamdar
committed
powerpc/papr_scm: don't requests stats with '0' sized stats buffer
JIRA: https://issues.redhat.com/browse/RHEL-81000 CVE: CVE-2022-49353 commit 07bf943 Author: Vaibhav Jain <[email protected]> Date: Tue May 24 16:53:53 2022 +0530 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/[email protected] Fixes: 0e0946e ("powerpc/papr_scm: Fix leaking nvdimm_events_map elements") Reported-by: Sachin Sant <[email protected]> Signed-off-by: Vaibhav Jain <[email protected]> Tested-by: Sachin Sant <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mamatha Inamdar <[email protected]>
1 parent 7457c49 commit 429d94c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu
465465
u32 available_events;
466466
int index, rc = 0;
467467

468+
if (!p->stat_buffer_len)
469+
return -ENOENT;
470+
468471
available_events = (p->stat_buffer_len - sizeof(struct papr_scm_perf_stats))
469472
/ sizeof(struct papr_scm_perf_stat);
470473
if (available_events == 0)

0 commit comments

Comments
 (0)