[Bug tools/32673] eu-strip SEGV (illegal read access) in gelf_getsymshndx (libelf/gelf_getsymshndx.c:123)

2025-02-13 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32673 Mark Wielaard changed: What|Removed |Added Assignee|unassigned at sourceware dot org |mark at klomp dot org

[Bug backends/32684] aarch64 linux 4 build failure: struct user_pac_mask not defined

2025-02-13 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32684 Mark Wielaard changed: What|Removed |Added CC||mark at klomp dot org --- Comment #1

[PATCH] strip: Verify symbol table is a real symbol table

2025-02-13 Thread Mark Wielaard
We didn't check the symbol table referenced from the relocation table was a real symbol table. This could cause a crash if that section happened to be an SHT_NOBITS section without any data. Fix this by adding an explicit check. * src/strip.c (INTERNAL_ERROR_MSG): New macro that takes a

[PATCH] scr: fix DEREF_OF_NULL.RET.STAT in ar.c

2025-02-13 Thread Anton Moryakov
Report of the static analyzer: 1. DEREF_OF_NULL.RET Pointer, returned from function 'elf_getarhdr' at ar.c:498, may be NULL and is dereferenced at ar.c:500. 2. DEREF_OF_NULL.RET Pointer, returned from function 'elf_getarhdr' at ar.c:940, may be NULL and is dereferenced at ar.c:943 3. DEREF_OF_NUL

[PATCH] src: fix DEREF_OF_NULL.RET.STAT in readelf.c in

2025-02-13 Thread Anton Moryakov
Static analyzer reported: Return value of a function 'gelf_getehdr' is dereferenced at readelf.c:12443 without checking for NULL, but it is usually checked for this function (53/54). Corrections explained: - Added a NULL check for the ehdr variable Triggers found by static analyzer Svace. Signed

[PATCH] src: fix DEREF_OF_NULL.RET.STAT in unstrip.c

2025-02-13 Thread Anton Moryakov
Static analyzer reported: Return value of a function 'elf_getdata' is dereferenced at unstrip.c:1977 without checking for NULL, but it is usually checked for this function (97/101). Corrections explained: - Added a check for NULL for the symstrdata variable before calling dwelf_strtab_finalize. -

Re: [PATCH] libdw: Simplify __libdw_getabbrev and fix dwarf_offabbrev issue

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 10:49 AM Mark Wielaard wrote: > > __libdw_getabbrev could crash on reading a bad abbrev by trying to > deallocate memory it didn't allocate itself. This could happen because > dwarf_offabbrev would supply its own memory when calling > __libdw_getabbrev. No other c

[PATCH] src: fix DEREF_OF_NULL.RET.STAT in readelf.c in

2025-02-13 Thread Anton Moryakov
Static analyzer reported: Return value of a function 'elf_strptr' is dereferenced at readelf.c:7171 without checking for NULL, but it is usually checked for this function (71/74). Corrections explained: - Added a NULL check for the scnname variable, which contains the result of the elf_strptr ca

Re: [PATCH] readelf: Handle NULL phdr in handle_dynamic_symtab

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 1:32 PM Mark Wielaard wrote: > > A corrupt ELF file can have broken program headers, in which case > gelf_getphdr returns NULL. This could crash handle_dynamic_symtab > while searching for the PT_DYNAMIC phdr. Fix this by checking whether > gelf_phdr returns NULL.

Re: [PATCH] readelf: Skip trying to uncompress sections without a name

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 1:37 PM Mark Wielaard wrote: > > When combining eu-readelf -z with -x or -p to dump the data or strings > in an (corrupted ELF) unnamed numbered section eu-readelf could crash > trying to check whether the section name starts with .zdebug. Fix this > by skipping s

Re: [PATCH] libelf, readelf: Use validate_str also to check dynamic symstr data

2025-02-13 Thread Aaron Merey
Hi Mark, On Mon, Feb 10, 2025 at 1:27 PM Mark Wielaard wrote: > > When dynsym/str was read through eu-readelf --dynamic by readelf > process_symtab the string data was not validated, possibly printing > unallocated memory past the end of the symstr data. Fix this by > truning the elf_strptr valid

[PATCH] src: fix DEREF_OF_NULL.RET in readelf.c

2025-02-13 Thread Anton Moryakov
Report of the static analyzer: DEREF_OF_NULL.RET Pointer, returned from function 'elf_getarhdr' at readelf.c:13551, may be NULL and is dereferenced at readelf.c:13553. Corrections explained: - Added a NULL check for the pointer returned by `elf_getarhdr`. - If the pointer is NULL, release resour

Re: [PATCH] libelf: Handle elf_strptr on section without any data

2025-02-13 Thread Aaron Merey
Hi Mark, On Wed, Feb 12, 2025 at 6:16 PM Mark Wielaard wrote: > > In the unlikely situation that elf_strptr was called on a section with > sh_size already set, but that doesn't have any data yet we could crash > trying to verify the string to return. > > This could happen for example when a new s

Re: [PATCH] strip: Verify symbol table is a real symbol table

2025-02-13 Thread Aaron Merey
Hi Mark, On Thu, Feb 13, 2025 at 9:04 AM Mark Wielaard wrote: > > We didn't check the symbol table referenced from the relocation table > was a real symbol table. This could cause a crash if that section > happened to be an SHT_NOBITS section without any data. Fix this by > adding an explicit che

[Bug libelf/32689] New: Robustify [g]elf functions that take (nobits) Elf_Data arguments

2025-02-13 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=32689 Bug ID: 32689 Summary: Robustify [g]elf functions that take (nobits) Elf_Data arguments Product: elfutils Version: unspecified Status: NEW Severity: normal