https://sourceware.org/bugzilla/show_bug.cgi?id=33456
Bug ID: 33456 Summary: [BUG] A heap-buffer-overflow in bfd_putl64 at libbfd.c:989 Product: binutils Version: 2.45 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: yfzhang23 at stu dot pku.edu.cn Target Milestone: --- Created attachment 16352 --> https://sourceware.org/bugzilla/attachment.cgi?id=16352&action=edit POC ## Description - Version: Binutils 2.45 - 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 --version-exports-section symbol --shared $POC ## Sanitizer output ==139072==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62100002a4e7 at pc 0x0000005d101f bp 0x7ffe081c8260 sp 0x7ffe081c8258 WRITE of size 1 at 0x62100002a4e7 thread T0 #0 0x5d101e in bfd_putl64 /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/libbfd.c:989:11 #1 0x62ee4a in elf_x86_64_finish_dynamic_symbol /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elf64-x86-64.c:5519:4 #2 0x74caa8 in elf_link_output_extsym /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elflink.c:11011:14 #3 0x5cd558 in bfd_hash_traverse /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/hash.c:814:8 #4 0x735ae2 in bfd_elf_final_link /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elflink.c:13258:3 #5 0x542fc9 in ldwrite /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/ldwrite.c:548:8 #6 0x53a80d in main /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/./ldmain.c:912:3 #7 0x7f15f1440082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) #8 0x41d69d in _start (/benchmark/bin/DAFL/ld-new-2025-1178+0x41d69d) 0x62100002a4e7 is located 7 bytes to the right of 4064-byte region [0x621000029500,0x62100002a4e0) allocated by thread T0 here: #0 0x49916d in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3 #1 0x9d1bd2 in _objalloc_alloc /benchmark/RUNDIR-binutils-2.45/binutils-2.45/libiberty/./objalloc.c:159:41 #2 0x5cf4fd in bfd_alloc /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/libbfd.c:453:9 #3 0x5cf6ba in bfd_zalloc /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/libbfd.c:478:9 #4 0x79f73b in alloc_trie_leaf /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/./dwarf2.c:153:10 #5 0x79f73b in _bfd_dwarf2_slurp_debug_info /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/./dwarf2.c:5451:24 #6 0x7ad7cc in _bfd_dwarf2_find_nearest_line_with_alt /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/./dwarf2.c:5817:9 #7 0x6cd6f4 in _bfd_elf_find_nearest_line_with_alt /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elf.c:9868:7 #8 0x6cd5c1 in _bfd_elf_find_nearest_line /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elf.c:9845:10 #9 0x554f06 in vfinfo /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/ldmisc.c:335:10 #10 0x557a09 in einfo /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/ldmisc.c:608:3 #11 0x53eb5e in multiple_definition /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/./ldmain.c #12 0x76a563 in _bfd_elf_merge_symbol /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elflink.c:1705:7 #13 0x7080e3 in elf_link_add_object_symbols /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elflink.c:5284:9 #14 0x7003a7 in bfd_elf_link_add_symbols /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/elflink.c:6416:14 #15 0x4f9770 in load_symbols /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/ldlang.c:3240:7 #16 0x516363 in open_input_bfds /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/ldlang.c:3732:13 #17 0x50b0ce in lang_process /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/ldlang.c:8323:3 #18 0x53a5b4 in main /benchmark/RUNDIR-binutils-2.45/binutils-2.45/ld/./ldmain.c:882:3 #19 0x7f15f1440082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) SUMMARY: AddressSanitizer: heap-buffer-overflow /benchmark/RUNDIR-binutils-2.45/binutils-2.45/bfd/libbfd.c:989:11 in bfd_putl64 Shadow bytes around the buggy address: 0x0c427fffd440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c427fffd450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c427fffd460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c427fffd470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x0c427fffd480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =>0x0c427fffd490: 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa 0x0c427fffd4a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c427fffd4b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c427fffd4c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c427fffd4d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c427fffd4e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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 ==139072==ABORTING ## Credit Reported by Yifan Zhang, [PLL](https://pl.cs.pku.edu.cn/en/) -- You are receiving this mail because: You are on the CC list for the bug.