arm: reject out-of-range relocations instead of reading and writing past the section
Binutils ARM ELF support now rejects relocations with fields outside section bounds and checks indirectly read instructions.
This series introduces bounds checking for ARM relocations in binutils to prevent out-of-bounds reads and writes. The first patch rejects relocations whose fields lie outside the section, and the second patch ensures that instructions indirectly read by specific relocations are also within section bounds. This addresses security vulnerabilities found via AddressSanitizer.
- proposer
Proposes a series of patches to reject out-of-range relocations and validate indirectly read instructions in ARM ELF.
“elf32_arm_relocate_section applies relocations at contents + r_offset without checking that the field lies inside the section, and three other paths read an instruction away from the field without checking it either. A crafted object can make ld read and write past the section.”
In Details
This cover letter introduces a two-patch series for binutils' ARM ELF backend, aiming to mitigate security risks identified by AddressSanitizer. The core issue is that the linker, when processing ARM object files, would sometimes read or write past the defined section boundaries due to crafted relocation offsets or indirectly accessed instructions. Patch 1 implements a general bounds check for the relocation field itself, mirroring existing checks in other backends. Patch 2 specifically addresses indirect reads of instructions by certain TLS and interworking relocations, ensuring those instru…
- AddressSanitizer
- A memory error detector for C/C++ that finds use-after-free, buffer overflows, and other memory safety issues.
- relocation
- A placeholder in object code that specifies how to modify an address or symbol reference when linking.
- ELF
- Executable and Linkable Format, a common standard file format for object files, executables, and shared libraries on Unix-like systems.
- ARM
- A family of reduced instruction set computing (RISC) architectures for processors, widely used in mobile and embedded systems.
- heap-buffer-overflow
- A type of buffer overflow where the overflow occurs in dynamically allocated memory (the heap).
- R_ARM_TLS_GOTDESC
- An ARM relocation type related to Thread-Local Storage (TLS) GOT (Global Offset Table) descriptor entries.
- R_ARM_V4BX
- An ARM relocation type associated with the BX (Branch and Exchange) instruction, used for interworking between ARM and Thumb states.
- R_ARM_THM_TLS_DESCSEQ
- An ARM relocation type for Thumb instructions related to TLS descriptor sequences.