binutils: Fix DWARF parsing segfaults from fuzzed objects
binutils: DWARF parsing now robust against malformed input, preventing segfaults.
The binutils DWARF parser has been hardened against malformed input that could lead to segmentation faults. Specifically, functions like get_or_create_enum_constant and get_or_create_subrange_type previously assumed correct ordering of DWARF tags, which fuzzed inputs violated. Assertions that incorrectly declared these invalid states as impossible have also been removed, improving robustness.
In Details
The insert_element_in_list function and its callers (get_or_create_enum_constant, get_or_create_subrange_type) in dwarf.c relied on the assumption that DWARF list pointers (e.g., enum_type_list, tab_type_list) were correctly set up by prior tags. Fuzzed inputs violate these ordering invariants, causing NULL pointer dereferences. The commit removes these assumptions and associated assertions, making the parsing more tolerant of malformed DWARF data.
- DWARF
- A standard debugging data format used by many compilers and debuggers to represent information about program variables, types, and structure in a portable way.
- tag
- In DWARF, a tag is a DW_TAG_* value that identifies the type of debugging information entry, such as DW_TAG_enumeration_type or DW_TAG_array_type.
- NULL pointer dereference
- An attempt to access memory at a NULL address, which typically results in a program crash (segmentation fault).