https://sourceware.org/bugzilla/show_bug.cgi?id=34784
Bug ID: 34784
Summary: GNU ld Alpha TLS relaxation underflows a global-symbol
hash index for a local resolver relocation
Product: binutils
Version: 2.46
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: basavesh.shivakumar at wsu dot edu
Target Milestone: ---
Created attachment 17104
--> https://sourceware.org/bugzilla/attachment.cgi?id=17104&action=edit
reproducer
I'm reporting this bug on behalf of my team: Emily West, Dr. Swarn Priya, Dr.
Peng Gao and Dr. Basavesh Ammanaghatta Shivakumar.
Summary
=======
A structurally valid Alpha ELF64 TLS-GD or TLS-LD object whose neighboring
R_ALPHA_LITERAL and R_ALPHA_HINT relocations name a local same-value resolver
alias makes elf64_alpha_relax_tls_get_addr subtract sh_info from local symbol
index 2 in an unsigned type and index the global symbol hash array with
ULONG_MAX: released GNU ld 2.46 under Valgrind records an invalid read of size
1 at elf64-alpha.c:3525 from address 0x18 before SIGSEGV, current binutils
commit 3d45f46c4818 reports unsigned pointer overflow at line 3860 and aborts,
while canonical global-symbol controls link cleanly; no invalid write or
accepted-output disclosure was observed.
Reproduction
============
1. Download and extract
`bfd-alpha-tls-local-resolver-symbol-index-underflow-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:
LD_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 structurally valid Alpha ELF64 TLS-GD or TLS-LD object whose neighboring
R_ALPHA_LITERAL and R_ALPHA_HINT relocations name a local same-value resolver
alias makes elf64_alpha_relax_tls_get_addr subtract sh_info from local symbol
index 2 in an unsigned type and index the global symbol hash array with
ULONG_MAX: released GNU ld 2.46 under Valgrind records an invalid read of size
1 at elf64-alpha.c:3525 from address 0x18 before SIGSEGV, current binutils
commit 3d45f46c4818 reports unsigned pointer overflow at line 3860 and aborts,
while canonical global-symbol controls link cleanly; no invalid write or
accepted-output disclosure was observed.
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 under Valgrind 3.26.0 records an invalid
read of size 1 at elf64-alpha.c:3525 from address 0x18, then SIGSEGV, for both
TLS-GD and TLS-LD local-resolver triggers; both canonical controls exit 0 with
zero errors.
* Current upstream source (PASS): Binutils commit 3d45f46c4818 (GNU ld
2.47.50.20261019) asserts at elf64-alpha.c:3858 and UBSan reports unsigned
pointer overflow at line 3860 before aborting for both triggers; both controls
exit 0.
* Instrumented build (PASS): UBSan attributes the pointer overflow to
elf64_alpha_relax_tls_get_addr line 3860, reached from
elf64_alpha_relax_section line 4291; no invalid write is claimed.
* Independent control (PASS): Canonical TLS-GD and TLS-LD global-resolver
controls exit 0 in the current plain build, while the corresponding local-alias
triggers assert and terminate with SIGSEGV.
* Duplicate review (REVIEWED): No matching global-hash index underflow was
found; reviewed Alpha TLS ordering/register/local-weak history and
distinguished the existing out-of-section write root.
--
You are receiving this mail because:
You are on the CC list for the bug.