]> git.baikalelectronics.ru Git - kernel.git/commit
s390/kdump: Fix elfcorehdr size calculation
authorPhilipp Rudo <prudo@linux.ibm.com>
Thu, 19 Jul 2018 09:13:45 +0000 (11:13 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 31 Jul 2018 15:43:43 +0000 (17:43 +0200)
commitfd31a13dac2fea9b82451e89ef495c11c9db8191
tree9350eed87fba41b5f7fee8744a079040cba4b6ae
parent9fe9ed886d220b5f77e9cccf3b2c9cbbcb51946d
s390/kdump: Fix elfcorehdr size calculation

Before the memory for the elfcorehdr is allocated the required size is
estimated with

       alloc_size = 0x1000 + get_cpu_cnt() * 0x4a0 +
               mem_chunk_cnt * sizeof(Elf64_Phdr);

Where 0x4a0 is used as size for the ELF notes to store the register
contend. This size is 8 bytes too small. Usually this does not immediately
cause a problem because the page reserved for overhead (Elf_Ehdr,
vmcoreinfo, etc.) is pretty generous. So usually there is enough spare
memory to counter the mis-calculated per cpu size. However, with growing
overhead and/or a huge cpu count the allocated size gets too small for the
elfcorehdr. Ultimately a BUG_ON is triggered causing the crash kernel to
panic.

Fix this by properly calculating the required size instead of relying on
magic numbers.

Fixes: 577b7a54904c2 ("s390/kdump: add support for vector extension")
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/crash_dump.c