zdump/dfi: Fix potential illegal memory access in kdump_init()

Before reading data at addresses 0x10418 and 0x10420 in kdump_init(),
validate 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 0x1000 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 15:26:15 +02:00
committed by Jan Höppner
parent 686c331b69
commit 64539853ca

View File

@@ -1074,6 +1074,10 @@ static void kdump_init(void)
{
unsigned long base, size;
if (!dfi_mem_range_valid(0x10418, sizeof(base)))
return;
if (!dfi_mem_range_valid(0x10420, sizeof(size)))
return;
dfi_mem_phys_read(0x10418, &base, sizeof(base));
dfi_mem_phys_read(0x10420, &size, sizeof(size));
if (base == 0 || size == 0)