Commit Graph

1 Commits

Author SHA1 Message Date
HATAYAMA Daisuke
5f7e55f54c gcore: fix memory allocation failure during processing NT_AUXV note
Backport from the upstream crash-gcore.

commit 4cb65a0d9168778d120920418b968d05da10989f
Author: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
Date:   Fri Feb 25 04:59:48 2022 -0500

    gcore: fix memory allocation failure during processing NT_AUXV note

    For crash dumps generated using kernel-4.18.0-365.el8 or later on
    CentOS stream 8, crash gcore command fails as follows:

        crash> gcore -v 7 -f 128 10604
        gcore: Opening file core.10604.test-dumpfilter ...
        gcore: done.
        gcore: Writing ELF header ...
        gcore:  done.
        gcore: Retrieving and writing note information ...
        gcore: zero-size memory allocation! (called from 7fd558ce1e05)
        Failed.

    This memory allocation failure occurs in fill_auxv_note() that creates
    NT_AUXV note due to saved_auxv entries of size and offset tables are
    somehow 0.

    This is because during the merge of the upstream kernel commit
    1c33bb0507508af24fd754dd7123bd8e997fab2f (x86/elf: Support a new ELF
    aux vector AT_MINSIGSTKSZ), location of saved_auxv of struct mm_struct
    has been moved as workaround in order to avoid kABI breakage.

    Fix this by using RHEL-specific location for saved_auxv if there is
    member rh_reserved_saved_auxv in struct mm_struct.

    Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>

Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
2022-07-26 15:13:40 +09:00