From 1d2316caef1e847533f655cf1d100a53f8684ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Fri, 1 Oct 2021 14:23:11 +0200 Subject: [PATCH] zdump/dfi_vmcoreinfo: Fix potential illegal memory access in os_info_get() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before reading data in os_info_get(), 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 98c05413..345d1da5 100644 --- a/zdump/dfi_vmcoreinfo.c +++ b/zdump/dfi_vmcoreinfo.c @@ -62,7 +62,8 @@ static struct os_info *os_info_get(void) static struct os_info os_info; unsigned long addr; - dfi_mem_read(LC_OS_INFO, &addr, sizeof(addr)); + if (dfi_mem_read_rc(LC_OS_INFO, &addr, sizeof(addr))) + return NULL; if (addr % 0x1000) return NULL; if (dfi_mem_read_rc(addr, &os_info, sizeof(os_info)))