arm: check the instructions that relocations read beside their field
Binutils arm ELF support now validates that instructions read by relocations are within section bounds.
This patch enhances binutils’ ARM ELF support by ensuring that instructions read by certain relocations (R_ARM_TLS_GOTDESC, R_ARM_V4BX, R_ARM_THM_TLS_DESCSEQ) are located within the section bounds. This prevents potential out-of-bounds reads and writes when processing crafted objects.
- proposer
Proposes adding checks for instruction bounds when read by relocations in ARM ELF.
“Three paths read section contents away from the relocated field, where the field check in elf32_arm_relocate_section does not reach: - R_ARM_TLS_GOTDESC: elf32_arm_final_link_relocate reads the field as the signed distance from the instruction that uses it, then reads that instruction. The distance comes from the input, so a crafted value read before or far outside the section. Check tha…”
In Details
This patch series (2/2) addresses security vulnerabilities in binutils' ARM ELF handling. Specifically, it adds bounds checks for instructions that are indirectly accessed by relocations like R_ARM_TLS_GOTDESC, R_ARM_V4BX, and R_ARM_THM_TLS_DESCSEQ. These checks ensure that the instruction being read, which might span across halfwords for Thumb instructions, is entirely contained within the section's boundaries, preventing heap overflows and other memory corruption issues on malformed inputs.
- relocation
- A placeholder in object code that specifies how to modify an address or symbol reference when linking.
- 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.
- Thumb
- A 16-bit instruction set architecture for ARM processors, designed for better code density.
- TLS
- Thread-Local Storage, a mechanism that allows each thread in a process to have its own private copy of a variable.
- GOT
- Global Offset Table, a table used in position-independent code to store addresses of external symbols or data.
- BFD
- Binary File Descriptor library, used by binutils to handle various object file formats.