https://sourceware.org/bugzilla/show_bug.cgi?id=35096
Bug ID: 35096
Summary: GNU ld ARM mismatched relocation target causes a NULL
stub-section dereference
Product: binutils
Version: 2.48 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: emily.west286 at gmail dot com
Target Milestone: ---
Created attachment 17324
--> https://sourceware.org/bugzilla/attachment.cgi?id=17324&action=edit
Reproduction materials
Product: binutils
Component: ld
Version: current master (716b214ad8db)
Host/target: Use an all-target GNU ld build, or a target build supporting the
emulation exercised by the attachment.
Summary
-------
Changing one ELF32 ARM section-flags byte removes allocation from the section
carrying TLS relocations; GNU ld continues after its missing-sgot assertion and
dereferences a NULL section pointer (globals->root.sgot) at elf32-arm.c:11918,
while the byte-matched control links.
Reproduction
------------
The archive contains the fixed input files, independent controls, helper
scripts needed by `repro.sh`, and their checksums.
1. Download and extract
`bfd-arm-tls-nonalloc-section-missing-got-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
Observed result
---------------
On current master (716b214ad8db, GNU ld 2.47.50.20261202) built with Clang
ASan+UBSan,
the trigger link aborts with:
control exit=0
trigger exit=134
/opt/bfd/ld-new: BFD (GNU Binutils) 2.47.50.20261202 assertion fail
../../bfd/elf32-arm.c:11575
../../bfd/elf32-arm.c:11918:34: runtime error: member access within null
pointer of type 'asection' (aka 'struct bfd_section')
==18==WARNING: invalid path to external symbolizer!
==18==WARNING: Failed to use and restart external symbolizer!
#0 0x55f2694d25d1 (/opt/bfd/ld-new+0x226f5d1) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#1 0x55f2694ee5e5 (/opt/bfd/ld-new+0x228b5e5) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#2 0x55f268cc286d (/opt/bfd/ld-new+0x1a5f86d) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#3 0x55f268cb7517 (/opt/bfd/ld-new+0x1a54517) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#4 0x55f2694c1b6d (/opt/bfd/ld-new+0x225eb6d) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#5 0x55f2686efd37 (/opt/bfd/ld-new+0x148cd37) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#6 0x55f2686e8b81 (/opt/bfd/ld-new+0x1485b81) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
#7 0x7fdc34fb5249 (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId:
93ac61ec5a8eb1396f9fbd350e3169a558528a40)
#8 0x7fdc34fb5304 (/lib/x86_64-linux-gnu/libc.so.6+0x27304) (BuildId:
93ac61ec5a8eb1396f9fbd350e3169a558528a40)
#9 0x55f2685c9690 (/opt/bfd/ld-new+0x1366690) (BuildId:
cdf54a78f712fddf693b6a6d40dd2b8a40f19f55)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../../bfd/elf32-arm.c:11918:34 in
timeout: the monitored command dumped core
Aborted
The control links cleanly.
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
----------
* Current upstream source (PASS): Master 716b214ad8db asserts on missing sgot
at elf32-arm.c:11575, then UBSan reports member access within a NULL asection
at elf32-arm.c:11918:34; the byte-matched control exits zero.
* Instrumented build (PASS): Fail-fast UBSan reports member access within null
pointer of type 'asection' at elf32-arm.c:11918:34.
* Independent control (PASS): The sh_flags=0x06 control exits zero on current
master.
* 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-tls-nonalloc-section-missing-got-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
replaces the BFD_ASSERT on sgot in the TLS branch of
elf32_arm_final_link_relocate
with a check that returns bfd_reloc_notsupported. Tested on master
716b214ad8db: the control exits 0, and the trigger reports "dangerous
relocation: unsupported relocation" with no sanitizer diagnostic.
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-tls-nonalloc-section-missing-got-null-dereference-reproducer.tar.gz`
`bfd-arm-tls-nonalloc-section-missing-got-null-dereference.patch`
`Dockerfile` (patch-test image; build with `--build-arg
PATCH=bfd-arm-tls-nonalloc-section-missing-got-null-dereference.patch`)
--
You are receiving this mail because:
You are on the CC list for the bug.