• Philipp Rudo's avatar
    s390/kdump: Fix elfcorehdr size calculation · 8cce437f
    Philipp Rudo authored
    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: a62bc073 ("s390/kdump: add support for vector extension")
    Signed-off-by: default avatarPhilipp Rudo <prudo@linux.ibm.com>
    Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
    8cce437f
crash_dump.c 17 KB