zdump/dfi_vmcoreinfo: Fix illegal memory access in dfi_vmcoreinfo_init()

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 <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Alexander Egorenkov
2021-08-31 17:13:38 +02:00
committed by Jan Höppner
parent 1d2316caef
commit 957e612720

View File

@@ -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, &note, sizeof(note)))