DWARF1 AT_sibling sanity check
Adds sanity check for DWARF Version 1 AT_sibling to prevent infinite loops from fuzzed object files.
This commit introduces a sanity check for the AT_sibling attribute in DWARF Version 1 debug information. It assumes AT_sibling pointers always point forward, a convention observed in GCC versions up to 3.3. This change prevents potential infinite loops when processing maliciously crafted object files, though it may affect compatibility with older DWARF v1 files that use backward sibling pointers.
In Details
The bfd/dwarf1.c file is updated to validate AT_sibling values during DWARF Version 1 parsing. The function parse_die now checks that the AT_sibling DIE pointer is within the current unit's bounds and does not point backward. This change simplifies the parsing logic by assuming forward-only sibling pointers, which were common in older GCC versions (<= 3.3) that supported DWARF v1, and aims to mitigate risks from malformed debug info. The function signature was also updated to use a stash pointer instead of abfd and aDiePtrEnd for better context management.
- DWARF
- A debugging information format used by many compilers and debuggers. It describes program structure, types, and variables to the debugger.
- AT_sibling
- A DWARF attribute that points to the next sibling Debugging Information Entry (DIE) in the same parent DIE.
- DIE
- Debugging Information Entry. A fundamental unit within the DWARF debugging format, representing a lexical block, function, type, or variable.
- bfd
- Binary File Descriptor library. This library provides a common interface for accessing various executable file formats, including reading symbol tables and debugging information.
- addr2line
- A utility that translates program addresses into line numbers and function names, typically by reading debugging information from an executable.
- objdump
- A utility that displays information from object files. The '-dS' option specifically shows disassembled code along with DWARF debug information.
- fuzzed object files
- Object files that have been intentionally modified with random or unexpected data, often used to test the robustness and security of parsers and tools.