https://sourceware.org/bugzilla/show_bug.cgi?id=33968

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
commit 13996f39dd0592064e297f014128acded82c67ec
Author: zengliwen <[email protected]>
Date:   Wed Nov 11 15:12:21 2026 +0800

    libelf: Avoid writing to read-only mmap in elf_update

    When an ELF file is opened with ELF_C_READ_MMAP, its mapping is
    created with PROT_READ.  For native-endian and suitably aligned ELF
    files, the ELF header currently points directly into that mapping.

    elf_update with ELF_C_NULL may update fields in the ELF header while
    calculating the file layout.  This attempts to write to the read-only
    mapping and can cause a segmentation fault.

    Keep a writable copy of the ELF header when the file is opened with
    ELF_C_READ_MMAP, as is already done for section headers.  Cover both
    ELF32 and ELF64, and exercise the read-only mmap path in
    test-manyfuncs.

    * libelf/elf_begin.c (file_read_elf): Copy the ELF header when using
      ELF_C_READ_MMAP.
    * tests/test-manyfuncs.c (check_elf): Exercise ELF_C_READ_MMAP.

    https://sourceware.org/bugzilla/show_bug.cgi?id=33968

    Signed-off-by: zengliwen <[email protected]>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to