From 168acec5ea3d4813f287cda04b588e03c9aa814d Mon Sep 17 00:00:00 2001 From: Mikhail Zaslonko Date: Tue, 27 Mar 2018 18:22:45 +0200 Subject: [PATCH] zgetdump: Avoid the Segfault on processing dumps with memory limit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When dump is not complete or dump memory limit is set, zgetdump might end up with the Segfault on reading Vector Registers. That might take place when the Vector Registers save area is beyond the dump memory limit. Signed-off-by: Mikhail Zaslonko Reviewed-by: Philipp Rudo Signed-off-by: Jan Höppner --- zdump/dfi.c | 6 +++++- zdump/dfi.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zdump/dfi.c b/zdump/dfi.c index 53053d23..3272d901 100644 --- a/zdump/dfi.c +++ b/zdump/dfi.c @@ -795,7 +795,10 @@ static void lc2cpu_64(struct dfi_cpu *cpu, struct dfi_lowcore_64 *lc) /* Add VX registers if available */ if (!dfi_cpu_lc_has_vx_sa(lc)) return; - dfi_mem_read(lc->vector_save_area_addr, &vx_sa, sizeof(vx_sa)); + if (dfi_mem_read_rc(lc->vector_save_area_addr, &vx_sa, sizeof(vx_sa))) { + STDERR("zgetdump: Vector registers save area is beyond dump memory limit for CPU %d\n", cpu->cpu_id); + return; + } memcpy(cpu->vxrs_high, &vx_sa[16 * 16], sizeof(cpu->vxrs_high)); for (i = 0; i < 16; i++) memcpy(&cpu->vxrs_low[i], &vx_sa[16 * i + 8], sizeof(u64)); @@ -827,6 +830,7 @@ void dfi_cpu_add_from_lc(u32 lc_addr) { struct dfi_cpu *cpu = dfi_cpu_alloc(); + cpu->cpu_id = l.cpus.cnt; switch (l.cpus.content) { case DFI_CPU_CONTENT_LC: cpu->prefix = lc_addr; diff --git a/zdump/dfi.h b/zdump/dfi.h index 113f418c..f591d999 100644 --- a/zdump/dfi.h +++ b/zdump/dfi.h @@ -97,6 +97,7 @@ struct dfi_cpu { u32 todpreg; u64 vxrs_low[16]; struct dfi_vxrs vxrs_high[16]; + u16 cpu_id; }; struct dfi_cpu_32 {