Created attachment 16393 [details] POC ## Description - Version: Binutils latest commit 9af366e0d3b7bc5802295bb001d17483033de87b - Environment: Ubuntu 20.04.6 LTS, Clang 12.0.0 ## Steps to reproduce export CC="clang" export CFLAGS="-g -fsanitize=address" ./configure make -j ./ld/ld-new --gc-sections --no-print-gc-sections -w $POC ## Sanitizer output ==67406==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62900000f1fb at pc 0x000000633818 bp 0x7ffeb5ab80d0 sp 0x7ffeb5ab80c8 READ of size 1 at 0x62900000f1fb thread T0 #0 0x633817 in elf_x86_64_relocate_section /benchmark/bin/DAFL/binutils-gdb/bfd/elf64-x86-64.c:4507:24 #1 0x7628ec in elf_link_input_bfd /benchmark/bin/DAFL/binutils-gdb/bfd/elflink.c:11963:10 #2 0x7547ff in bfd_elf_final_link /benchmark/bin/DAFL/binutils-gdb/bfd/elflink.c:13222:11 #3 0x542f2e in ldwrite /benchmark/bin/DAFL/binutils-gdb/ld/ldwrite.c:548:8 #4 0x53acdf in main /benchmark/bin/DAFL/binutils-gdb/ld/./ldmain.c:905:3 #5 0x785f1333ed8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) #6 0x785f1333ee3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) #7 0x41d6c4 in _start (/benchmark/bin/DAFL/binutils-gdb/ld/ld-new+0x41d6c4) 0x62900000f1fb is located 5 bytes to the left of 16384-byte region [0x62900000f200,0x629000013200) allocated by thread T0 here: #0 0x49919d in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3 #1 0x5d9812 in bfd_malloc /benchmark/bin/DAFL/binutils-gdb/bfd/libbfd.c:291:9 #2 0x75356a in bfd_elf_final_link /benchmark/bin/DAFL/binutils-gdb/bfd/elflink.c:13097:38 #3 0x542f2e in ldwrite /benchmark/bin/DAFL/binutils-gdb/ld/ldwrite.c:548:8 #4 0x53acdf in main /benchmark/bin/DAFL/binutils-gdb/ld/./ldmain.c:905:3 #5 0x785f1333ed8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) SUMMARY: AddressSanitizer: heap-buffer-overflow /benchmark/bin/DAFL/binutils-gdb/bfd/elf64-x86-64.c:4507:24 in elf_x86_64_relocate_section Shadow bytes around the buggy address: 0x0c527fff9de0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c527fff9df0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c527fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c527fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c527fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c527fff9e30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa] 0x0c527fff9e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c527fff9e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c527fff9e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c527fff9e70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c527fff9e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb Shadow gap: cc ==67406==ABORTING ## Credit Reported by Yifan Zhang, [PLL](https://pl.cs.pku.edu.cn/en/)
*** Bug 33451 has been marked as a duplicate of this bug. ***
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6b21c8b2ecfef5c95142cbc2c32f185cb1c26ab0 commit 6b21c8b2ecfef5c95142cbc2c32f185cb1c26ab0 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Sep 30 08:18:29 2025 +0800 x86: Disallow TLS relocation in non executable section Since TLS relocations are applied to executable machine instructions, disallow TLS relocation in non-SHT_PROGBITS, non-SHF_EXECINSTR section. PR ld/33451 PR ld/33502 * elf32-i386.c (elf_i386_tls_transition): Disallow TLS relocation in non-SHT_PROGBITS, non-SHF_EXECINSTR section. (elf_i386_scan_relocs): Likewise. * elf64-x86-64.c (elf_x86_64_tls_transition): Likewise. (elf_x86_64_scan_relocs): Likewise. * elfxx-x86.c (_bfd_x86_elf_link_report_tls_invalid_section_error): New. * elfxx-x86.h (_bfd_x86_elf_link_report_tls_invalid_section_error): Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Fixed.
I cannot reproduce this on version 2.40. Is 2.40 not affected by this CVE?