https://sourceware.org/bugzilla/show_bug.cgi?id=34842
Bug ID: 34842
Summary: GNU ld SH, RL78, and RX relaxers shift by unvalidated
alignment exponents
Product: binutils
Version: 2.48 (HEAD)
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 17162
--> https://sourceware.org/bugzilla/attachment.cgi?id=17162&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
=======
GNU ld --relax on the included SH, RL78, and RX objects with
alignment-relocation addend -1 evaluates 1 << exponent without bounding the
relocation-controlled exponent; current UBSan attributes stable reports twice
per backend to bfd/elf32-sh.c:867, bfd/elf32-rl78.c:2209, and
bfd/elf32-rx.c:2173, while the included literal expressions are at lines 870,
2215, and 2176 respectively; safe-exponent controls are sanitizer-clean twice,
and the GNU ld 2.46 Memcheck replay establishes no released UBSan conclusion.
Reproduction
============
1. Download and extract
`bfd-relax-negative-addend-shift-ubsan-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=/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
===============
GNU ld --relax on the included SH, RL78, and RX objects with
alignment-relocation addend -1 evaluates 1 << exponent without bounding the
relocation-controlled exponent; current UBSan attributes stable reports twice
per backend to bfd/elf32-sh.c:867, bfd/elf32-rl78.c:2209, and
bfd/elf32-rx.c:2173, while the included literal expressions are at lines 870,
2215, and 2176 respectively; safe-exponent controls are sanitizer-clean twice,
and the GNU ld 2.46 Memcheck replay establishes no released UBSan conclusion.
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.