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

            Bug ID: 35103
           Summary: bfd/elf32-ppc.c:8255: GNU ld PPC32 relocation
                    dereferences a missing PLT entry
           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 17336
  --> https://sourceware.org/bugzilla/attachment.cgi?id=17336&action=edit
Reproducer

Product: binutils
Component: ld
Version: current master (a76487344054)
Host/target: PowerPC32 ELF (elf32ppclinux)

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
-------

A relaxed PPC32 call whose PLT entry was never created makes ld read a member
of a NULL plt_entry at bfd/elf32-ppc.c:8255.

Reproduction
------------

1. Extract `bfd-ppc32-relocate-missing-plt-entry-reproducer.tar.gz`.
2. Run:

       LD=/path/to/ld-new sh repro.sh

   Without a local build, use the `bfd-repro` image:

       docker run --rm -v "$PWD:/queue:ro" bfd-repro \
        
/queue/attachments/bfd-ppc32-relocate-missing-plt-entry-reproducer.tar.gz

Observed result
---------------

Master a76487344054 built with Clang ASan+UBSan. UBSan report:

    ../../bfd/elf32-ppc.c:8255:17: runtime error: member access within null
pointer of type 'struct plt_entry'
    ==18==WARNING: invalid path to external symbolizer!
    ==18==WARNING: Failed to use and restart external symbolizer!
        #0 0x560b4c293abc  (/opt/bfd/ld-new+0x24baabc) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
        #1 0x560b4b83886d  (/opt/bfd/ld-new+0x1a5f86d) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
        #2 0x560b4b82d517  (/opt/bfd/ld-new+0x1a54517) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
        #3 0x560b4b265d37  (/opt/bfd/ld-new+0x148cd37) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
        #4 0x560b4b25eb81  (/opt/bfd/ld-new+0x1485b81) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)
        #5 0x7f235a4e0249  (/lib/x86_64-linux-gnu/libc.so.6+0x27249) (BuildId:
93ac61ec5a8eb1396f9fbd350e3169a558528a40)
        #6 0x7f235a4e0304  (/lib/x86_64-linux-gnu/libc.so.6+0x27304) (BuildId:
93ac61ec5a8eb1396f9fbd350e3169a558528a40)
        #7 0x560b4b13f690  (/opt/bfd/ld-new+0x1366690) (BuildId:
e954f11978a1462c93a1fefa94c533268ef8adb3)

    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../../bfd/elf32-ppc.c:8255:17 in
    Aborted (core dumped)

The control exits 0 with no diagnostics.

Expected result
---------------

ld should reject the input with a normal diagnostic, without reading a member
of a NULL PLT entry.

Validation
----------

* Master a76487344054, Clang ASan+UBSan: trigger aborts at elf32-ppc.c:8255:17;
control exits 0.
* With the suggested patch: trigger exits 1 with "no PLT entry for relaxed call
against `tvar_0'" and "final link failed"; control exits 0.
* Duplicate check (2026-12-03): no matching Sourceware report found.

Suggested fix
-------------

`bfd-ppc32-relocate-missing-plt-entry.patch` checks for a missing PLT entry
before using it, reports "no PLT entry for relaxed call", and rejects the
input. Test image: `patch.Dockerfile`, built with
`--build-arg PATCH=bfd-ppc32-relocate-missing-plt-entry.patch`.

Scope
-----

No invalid write across a security boundary is established.

Attachment
----------

- `bfd-ppc32-relocate-missing-plt-entry-reproducer.tar.gz`
- `bfd-ppc32-relocate-missing-plt-entry.patch`

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

Reply via email to