https://sourceware.org/bugzilla/show_bug.cgi?id=34785

            Bug ID: 34785
           Summary: GNU ld a.out external relocation symbol index is
                    unchecked
           Product: binutils
           Version: 2.46
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: basavesh.shivakumar at wsu dot edu
  Target Milestone: ---

Created attachment 17105
  --> https://sourceware.org/bugzilla/attachment.cgi?id=17105&action=edit
reproducer

Summary
=======

GNU ld indexes standard-a.out symbol arrays with an unchecked 24-bit external
relocation index; a one-past index causes a current-head heap-buffer-overflow
read and large indices crash GNU ld 2.46, while the last-valid-index control
links.

Reproduction
============

1. Download and extract
`bfd-aout-ns32k-external-reloc-index-oob-read-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
===============

GNU ld indexes standard-a.out symbol arrays with an unchecked 24-bit external
relocation index; a one-past index causes a current-head heap-buffer-overflow
read and large indices crash GNU ld 2.46, while the last-valid-index control
links.

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.0 SIGSEGVs for external indices 65535
and 16777215 on relocatable and final routes; it accepts the one-past index on
-r and the included matrix records the garbage-name final rejection.
* Current upstream source (PASS): Binutils master ab7102f76c08 reports a
heap-buffer-overflow read for exact one-past index 9 at aoutx.h:4103 on -r and
invalid reads for the larger indices on both routes.
* Instrumented build (PASS): ASan attributes index 9 to the four-byte
symbol_map read at aoutx.h:4103; UBSan/ASan attribute large-index paths to
unchecked sym_hashes accesses at aoutx.h:4069 and 4200.
* Independent control (PASS): The base index 6 and one-field last-valid index 8
controls link cleanly on both current and released subjects; shrinking a_syms
is included only as a same-root manifestation.
* Duplicate review (REVIEWED): No matching Sourceware report was identified
during review.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to