binutils: od-xcoff: bound XCOFF traceback tag parsing
Hardens XCOFF parsing by bounding traceback tag parsing, preventing heap buffer overflows from malformed input.
This patch enhances the robustness of the XCOFF dumper by adding bounds checking to the traceback tag parsing. Previously, malformed traceback tags could lead to heap buffer overflows by reading past the allocated buffer. The changes ensure that parsing stops if fewer than 4 bytes remain for critical data and validate all optional fields against the remaining section size.
- proposer
Implements bounds checking for XCOFF traceback tag parsing to prevent heap buffer overflows.
“dump_xcoff32_tbtags parses the traceback table that follows an XCOFF function body. The parsing loop and several optional fields advanced an offset through the section buffer without checking against the section size. A malformed traceback tag could read past the allocated buffer (AddressSanitizer: heap-buffer-overflow). Stop the scan when fewer than 4 bytes remain for the next zero word, and…”
In Details
This patch in the od-xcoff hardening series adds bounds checking to the parsing of XCOFF traceback tags. It prevents heap overflows by validating offsets and lengths against the available section size. The changes ensure that malformed tag data, including issues with symbol values relative to the .text section and various optional fields, is handled gracefully without corrupting memory. New test cases are included to cover these scenarios.
- XCOFF
- A file format used on IBM AIX systems, similar to COFF and ELF.
- traceback table
- A section in an object file that contains information used for debugging and stack unwinding, especially for exceptions.
- heap buffer overflow
- A vulnerability where a program writes data beyond the allocated buffer in the heap, potentially corrupting adjacent memory.
- .text section
- The section in an object file that typically contains the executable code of a program.