Created attachment 16882 [details] PoC Summary During relocatable link (`-r`), placing an orphan section dereferences a NULL pointer in `elf_orphan_compatible` (`ld/ldelf.c:2092`, called from `ldelf_place_orphan`). A malformed input section that becomes an orphan has no compatible output section, and the comparison routine dereferences a NULL section pointer. This issue may be an incomplete fix for bug 32647. Affected Version - binutils 2.47 (release tarball, version date `20260726`) - Originally triaged on dev snapshot `2.47.50.20260722` (commit `640a79623`). Reproduction Build (ASAN): CC=gcc CFLAGS='-g -O1 -fsanitize=address -fno-omit-frame-pointer -fno-common' \ LDFLAGS='-fsanitize=address' \ ./configure --disable-gdb --disable-gdbserver --disable-sim --disable-cet \ --disable-werror --disable-nls --enable-targets=x86_64-linux-gnu MAKEINFO=true make -j Run: export ASAN_OPTIONS="abort_on_error=0:symbolize=1:detect_leaks=0:allocator_may_return_null=1:halt_on_error=1" ld -r -o /dev/null bug_2.o Error Log ==65001==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000058 (pc 0x59545d4b3edb bp 0x7ffd2939edf0 sp 0x7ffd2939ed70 T0) The signal is caused by a READ memory access. #0 elf_orphan_compatible /home/user/build/binutils-2.47/ld/ldelf.c:2092 #1 ldelf_place_orphan /home/user/build/binutils-2.47/ld/ldelf.c:2259 #2 ldemul_place_orphan /home/user/build/binutils-2.47/ld/ldemul.c:152 #3 ldlang_place_orphan /home/user/build/binutils-2.47/ld/ldlang.c:7815 #4 lang_place_orphans /home/user/build/binutils-2.47/ld/ldlang.c:7871 SUMMARY: AddressSanitizer: SEGV /home/user/build/binutils-2.47/ld/ldelf.c:2092 in elf_orphan_compatible
I can reproduce it since at least 2.42: ./ld/ld-new: unknown architecture of input file `/home/ebeer/Downloads/bug_2.o' is incompatible with i386:x86-64 output AddressSanitizer:DEADLYSIGNAL ================================================================= ==579183==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000060 (pc 0x000000468246 bp 0x7ffe3554aa60 sp 0x7ffe3554a9e0 T0) ==579183==The signal is caused by a READ memory access. ==579183==Hint: address points to the zero page. #0 0x000000468246 in elf_orphan_compatible /tmp/binutils-42/ld/ldelf.c:2089 #1 0x000000468246 in ldelf_place_orphan /tmp/binutils-42/ld/ldelf.c:2253 #2 0x000000448a7c in ldemul_place_orphan /tmp/binutils-42/ld/ldemul.c:144 #3 0x000000437743 in ldlang_place_orphan /tmp/binutils-42/ld/ldlang.c:7420 #4 0x000000437743 in lang_place_orphans /tmp/binutils-42/ld/ldlang.c:7476 #5 0x000000437743 in lang_process /tmp/binutils-42/ld/ldlang.c:8375 #6 0x00000043fbd4 in main ldmain.c:501 #7 0x7ff379e2b53d in __libc_start_call_main (/lib64/libc.so.6+0x2b53d) (BuildId: aa9d4edc4e25f8842c8f1e29eaaaf78a6197b3d7) #8 0x7ff379e2b66a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2b66a) (BuildId: aa9d4edc4e25f8842c8f1e29eaaaf78a6197b3d7) #9 0x000000404ad4 in _start ../sysdeps/x86_64/start.S:115 ==579183==Register values: rax = 0x0000000000000080 rbx = 0x00007e0378bfc638 rcx = 0x0000000000000000 rdx = 0x00007e0378c04658 rdi = 0x000000000000000c rsi = 0x00007e0378bf1bf0 rbp = 0x00007ffe3554aa60 rsp = 0x00007ffe3554a9e0 r8 = 0x0000000000000060 r9 = 0x0000000000000000 r10 = 0x00007e0378bf788f r11 = 0x0000000000000000 r12 = 0x00007e0378bef510 r13 = 0x0000000000000000 r14 = 0x00000fc06f17f8cb r15 = 0x0000000000000007 AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /tmp/binutils-42/ld/ldelf.c:2089 in elf_orphan_compatible ==579183==ABORTING 2.41 only shows the "incompatible" line but does not crash, but I have not tried any harder if it would work there as well.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=123e4a5eab2db300b44288dcc1a29c903f9622f9 commit 123e4a5eab2db300b44288dcc1a29c903f9622f9 Author: Alan Modra <amodra@gmail.com> Date: Tue Sep 22 21:27:03 2026 +0930 PR 34450 SEGV in elf_orphan_compatible Don't trust that SHF_LINK_ORDER set means linked_to is non-NULL. * ldelf.c (elf_orphan_compatible): Sanity check linked_to before dereferencing.
Fixed for 2.48
FYI: this is CVE-2026-90828