zdump/dfi_vmcoreinfo: Fix potential illegal memory access in os_info_get()

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 <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Höppner
2021-10-01 14:23:11 +02:00
parent 64539853ca
commit 1d2316caef

View File

@@ -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)))