binutils: od-xcoff: validate relocation symbol slots
Hardens XCOFF parsing by validating relocation symbol slots, preventing crashes from malformed auxiliary symbol data.
This patch addresses a vulnerability in the XCOFF dumper where malformed auxiliary symbol data in relocations could lead to crashes. It tracks primary symbol slots and only prints symbol names for them, falling back to numeric indices for auxiliary slots. This prevents dereferencing invalid pointers and introduces tests to cover these scenarios.
- proposer
Introduces validation for XCOFF relocation symbol slots to prevent crashes caused by malformed auxiliary symbol data.
“xcoff32_print_symbol checks symndx against nsyms, then dereferences syms[symndx].sym.name. A relocation may name an auxiliary symbol slot; the union overlays sym.name with aux data, so a malformed aux record can turn that pointer into an arbitrary value. objdump -P relocs then dereferences it and crashes (AddressSanitizer: SEGV). Track which symbol slots are primary records while reading the t…”
In Details
The final patch in this series focuses on hardening the od-xcoff dumper against malformed XCOFF files. It specifically targets how relocations refer to symbol slots. By differentiating between primary and auxiliary symbol entries, it prevents heap buffer overflows and segmentation faults that could occur when a relocation points to corrupted auxiliary data, ensuring that only valid symbol names are dereferenced.
- XCOFF
- A file format used on IBM AIX systems, similar to COFF and ELF.
- relocation
- Information in an object file that describes how to modify code or data addresses after linking.
- symbol slot
- An entry in the symbol table of an object file, representing a variable, function, or other named entity.
- auxiliary symbol data
- Additional information associated with a primary symbol entry in some object file formats, like XCOFF.
- objdump -P
- A command-line option for
objdumpused to display relocation information.