From 957e61272068699a8e1f30736d3276ea8f8f907d Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Tue, 31 Aug 2021 17:13:38 +0200 Subject: [PATCH] zdump/dfi_vmcoreinfo: Fix illegal memory access in dfi_vmcoreinfo_init() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before reading data in dfi_vmcoreinfo_init(), check the validity of the memory range. Otherwise this can result in a segmentation fault when zgetdump is given a very small dump, e.g. S390 DASD single-volume dump of size 0x10 bytes. Signed-off-by: Alexander Egorenkov Signed-off-by: Jan Höppner --- zdump/dfi_vmcoreinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zdump/dfi_vmcoreinfo.c b/zdump/dfi_vmcoreinfo.c index 345d1da5..682f8bf2 100644 --- a/zdump/dfi_vmcoreinfo.c +++ b/zdump/dfi_vmcoreinfo.c @@ -90,7 +90,8 @@ void dfi_vmcoreinfo_init(void) addr = l.os_info->vmcoreinfo_addr; size = l.os_info->vmcoreinfo_size; } else { - dfi_mem_read(LC_VMCORE_INFO, &addr, sizeof(addr)); + if (dfi_mem_read_rc(LC_VMCORE_INFO, &addr, sizeof(addr))) + return; if (addr == 0) return; if (dfi_mem_read_rc(addr, ¬e, sizeof(note)))