aarch64: reject out-of-range relocations instead of writing past the section
Binutils AArch64 ELF support now rejects relocations with fields outside section bounds and validates TLS relaxation spans.
This series addresses security vulnerabilities in binutils’ AArch64 ELF handling by adding bounds checks for relocations and TLS relaxation. The first patch rejects relocations whose fields lie outside section boundaries, and the second patch validates TLS relaxation spans and sequence lengths. These changes prevent out-of-bounds reads and writes on crafted objects.
- proposer
Proposes a series of patches to reject out-of-range relocations and validate TLS relaxation spans in AArch64 ELF.
“elfNN_aarch64_relocate_section and elfNN_aarch64_tls_relax write into the section contents at the relocation offset without checking that the field, or the relaxed instruction sequence, lies inside the section. A crafted object can make ld read and write past the section.”
In Details
This cover letter introduces a two-patch series for binutils' AArch64 ELF backend, addressing security concerns related to out-of-bounds memory access. The patches implement per-backend checks similar to those in x86 ELF backends. Patch 1 adds a check to elfNN_aarch64_relocate_section to ensure relocation fields, considering their actual write size, are within section bounds, preventing heap overflows. Patch 2 focuses on TLS relaxation, adding checks to elfNN_aarch64_tls_relax to ensure that the rewritten instruction sequences and subsequent relocation reads do not go out of bounds. This…
- 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.
- AArch64
- The 64-bit ARM architecture.
- TLS
- Thread-Local Storage, a mechanism allowing each thread in a process to have its own private copy of a variable.
- relaxation
- An optimization process where the linker adjusts code or data references, often to create position-independent code or to enable specific features like TLS.
- heap-buffer-overflow
- A type of buffer overflow where the overflow occurs in dynamically allocated memory (the heap).
- R_AARCH64_TLS_DTPREL
- An AArch64 relocation type used for Thread-Local Storage (TLS) data access.