https://sourceware.org/bugzilla/show_bug.cgi?id=34804
Bug ID: 34804
Summary: GNU ld (BFD) segfaults on lone i386 relocations with
no howto (R_386_32PLT and the Sun TLS GD/LDM types)
Product: binutils
Version: 2.47
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 17124
--> https://sourceware.org/bugzilla/attachment.cgi?id=17124&action=edit
repro
I'm reporting this bug on behalf of my team: Ananta Srikar Puranam, Emily West,
Dr. Swarn Priya, Dr. Peng Gao and Dr. Basavesh Ammanaghatta Shivakumar.
Summary
=======
Released GNU ld 2.46 linking an i386 static executable, PIE or shared object
whose only relocation is R_386_32PLT (11) or one of the eight Sun TLS GD/LDM
types (24-31) dereferences a NULL howto in elf_i386_scan_relocs via
bfd_get_reloc_size during dynamic-section sizing and dies with SIGSEGV. An
recorded ASan+UBSan build of exact upstream HEAD
2c4ccb8103d73917d769cf6c35fa8b71424f20ca reproduces all nine final-mode
failures as a symbolized NULL-member access at bfd.h:3323 through
elf32-i386.c:1596; all nine -r inputs reject cleanly and the R_386_32 control
succeeds in every mode. Pre-regression GNU ld 2.44 rejects cleanly. Gold, LLD
and mold reject the nine final links without process failure; gold and LLD
accept them under -r, while the released mold 2.40.4 matrix records status 134
there as a separate-project root. This is the unfixed i386 half of PR ld/33018;
the x86-64 twin was fixed by 04395ea00492, and d4d66eb19fd5 introduced the
unchecked size test in 2.45.
Reproduction
============
1. Download and extract
`bfd-i386-scan-relocs-null-howto-segv-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:
LINKERS=/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
===============
Released GNU ld 2.46 linking an i386 static executable, PIE or shared object
whose only relocation is R_386_32PLT (11) or one of the eight Sun TLS GD/LDM
types (24-31) dereferences a NULL howto in elf_i386_scan_relocs via
bfd_get_reloc_size during dynamic-section sizing and dies with SIGSEGV. An
recorded ASan+UBSan build of exact upstream HEAD
2c4ccb8103d73917d769cf6c35fa8b71424f20ca reproduces all nine final-mode
failures as a symbolized NULL-member access at bfd.h:3323 through
elf32-i386.c:1596; all nine -r inputs reject cleanly and the R_386_32 control
succeeds in every mode. Pre-regression GNU ld 2.44 rejects cleanly. Gold, LLD
and mold reject the nine final links without process failure; gold and LLD
accept them under -r, while the released mold 2.40.4 matrix records status 134
there as a separate-project root. This is the unfixed i386 half of PR ld/33018;
the x86-64 twin was fixed by 04395ea00492, and d4d66eb19fd5 introduced the
unchecked size test in 2.45.
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.
--
You are receiving this mail because:
You are on the CC list for the bug.