https://sourceware.org/bugzilla/show_bug.cgi?id=35088
Bug ID: 35088
Summary: GNU ld ARM dereferences missing local GOT offsets
after a rejected PIE relocation
Product: binutils
Version: 2.48 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libctf
Assignee: unassigned at sourceware dot org
Reporter: emily.west286 at gmail dot com
Target Milestone: ---
Created attachment 17317
--> https://sourceware.org/bugzilla/attachment.cgi?id=17317&action=edit
Reproduction materials
Product: binutils
Component: ld
Version: 2.46
Host/target: Use an all-target GNU ld build, or a target build supporting the
emulation exercised by the attachment.
Summary
-------
A 976-byte ELF32 ARM object that first triggers a rejected non-PIC PIE
relocation makes GNU ld continue with uninitialized GOT bookkeeping; current
fail-fast UBSan aborts while reading a NULL local-GOT-offset array at
bfd/elf32-arm.c:11441, and GNU ld 2.46 terminates with SIGSEGV. The same input
links cleanly with -r.
Reproduction
------------
1. Download and extract
`bfd-arm-local-got-offsets-null-dereference-reproducer.tar.gz`.
2. Run the following command with an ld.bfd or all-target `ld-new` binary that
supports the emulation used by the reproducer:
BFD=/path/to/ld-new sh repro.sh
The archive contains the fixed input files, independent controls, helper
scripts needed by `repro.sh`, and their checksums. The script uses a temporary
directory and does not modify the source tree.
Observed result
---------------
A 976-byte ELF32 ARM object that first triggers a rejected non-PIC PIE
relocation makes GNU ld continue with uninitialized GOT bookkeeping; current
fail-fast UBSan aborts while reading a NULL local-GOT-offset array at
bfd/elf32-arm.c:11441, and GNU ld 2.46 terminates with SIGSEGV. The same input
links cleanly with -r.
Expected result
---------------
GNU ld should either produce the correct output or reject the input with a
normal diagnostic. It should not crash, hang, execute undefined behavior, read
outside an input-derived allocation, or produce the described malformed
output.
Validation
----------
* Released version (PASS): GNU ld 2.46 emits the corresponding assertions and
terminates with SIGSEGV.
* Current upstream source (PASS): Binutils commit 36f4993daf0a reproduces the
NULL local-GOT-offset read at elf32-arm.c:11441.
* Instrumented build (PASS): Fail-fast UBSan reports non-zero pointer
arithmetic from NULL at elf32-arm.c:11441:10.
* Independent control (PASS): The same object links cleanly in relocatable mode
on current and released builds.
* Duplicate review (REVIEWED): No exact matching Sourceware report was found in
the review completed on 2026-10-29.
Suggested fix
-------------
A suggested patch is provided as
bfd-arm-local-got-offsets-null-dereference.patch,
and a Dockerfile that builds current master with the patch applied is provided
as Dockerfile (both in the patches directory of the filing queue). The patch
makes elf32_arm_final_link_relocate return bfd_reloc_notsupported instead of
reading the NULL local GOT array at bfd/elf32-arm.c:11439, and does the same in
the local TLS branch. Tested on master 716b214ad8db: the trigger reports
"dangerous relocation: unsupported relocation" with no sanitizer diagnostic,
and the -r control still exits 0.
Scope
-----
This is a public robustness or correctness report. The observed behavior does
not establish an invalid write across a security boundary, code execution,
privilege gain, or a vulnerability introduced into otherwise safe generated
output.
Attachment
----------
`bfd-arm-local-got-offsets-null-dereference-reproducer.tar.gz`
`bfd-arm-local-got-offsets-null-dereference.patch`
`Dockerfile for running the suggested patch (build with `--build-arg
PATCH=bfd-arm-local-got-offsets-null-dereference.patch`)
--
You are receiving this mail because:
You are on the CC list for the bug.