https://sourceware.org/bugzilla/show_bug.cgi?id=33453
Bug ID: 33453
Summary: [BUG] A heap-buffer-overflow in
_bfd_elf_write_section_eh_frame at elf-eh-frame.c:1996
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 16349
--> https://sourceware.org/bugzilla/attachment.cgi?id=16349&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
==139062==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x6210000290e0 at pc 0x00000049885c bp 0x7ffc091d5d70 sp 0x7ffc091d5538
WRITE of size 131012 at 0x6210000290e0 thread T0
#0 0x49885b in __asan_memset
/src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:26:3
#1 0x7bf018 in _bfd_elf_write_section_eh_frame
/benchmark/bin/binutils-2.45/bfd/elf-eh-frame.c:1996:2
#2 0x677ea2 in _bfd_x86_elf_finish_dynamic_sections
/benchmark/bin/binutils-2.45/bfd/elfxx-x86.c:2899:10
#3 0x642cef in elf_x86_64_finish_dynamic_sections
/benchmark/bin/binutils-2.45/bfd/elf64-x86-64.c:5637:10
#4 0x760c73 in bfd_elf_final_link
/benchmark/bin/binutils-2.45/bfd/elflink.c:13730:13
#5 0x545133 in ldwrite /benchmark/bin/binutils-2.45/ld/ldwrite.c:548:8
#6 0x53cc51 in main /benchmark/bin/binutils-2.45/ld/./ldmain.c:912:3
#7 0x7f53fe884082 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x24082)
#8 0x41d6ad in _start (/benchmark/bin/binutils-2.45/ld/ld-new+0x41d6ad)
0x6210000290e0 is located 0 bytes to the right of 4064-byte region
[0x621000028100,0x6210000290e0)
allocated by thread T0 here:
#0 0x49917d in malloc
/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
#1 0xa142f6 in _objalloc_alloc
/benchmark/bin/binutils-2.45/libiberty/./objalloc.c:159:41
#2 0x5dd3a0 in bfd_alloc /benchmark/bin/binutils-2.45/bfd/libbfd.c:453:9
#3 0x5dd45c in bfd_zalloc /benchmark/bin/binutils-2.45/bfd/libbfd.c:478:9
#4 0x6c30be in _bfd_elf_new_section_hook
/benchmark/bin/binutils-2.45/bfd/elf.c:3260:47
#5 0x6020b3 in bfd_section_init
/benchmark/bin/binutils-2.45/bfd/section.c:847:9
#6 0x6023b8 in bfd_make_section_anyway_with_flags
/benchmark/bin/binutils-2.45/bfd/section.c:1206:10
#7 0x687c2d in _bfd_x86_elf_link_setup_gnu_properties
/benchmark/bin/binutils-2.45/bfd/elfxx-x86.c:4747:10
#8 0x64912c in elf_x86_64_link_setup_gnu_properties
/benchmark/bin/binutils-2.45/bfd/elf64-x86-64.c:6246:10
#9 0x5975ae in ldelf_after_open
/benchmark/bin/binutils-2.45/ld/ldelf.c:1294:3
#10 0x570b83 in gldelf_x86_64_after_open
/benchmark/bin/binutils-2.45/ld/eelf_x86_64.c:161:3
#11 0x5549f7 in ldemul_after_open
/benchmark/bin/binutils-2.45/ld/ldemul.c:80:3
#12 0x50c849 in lang_process
/benchmark/bin/binutils-2.45/ld/ldlang.c:8503:3
#13 0x53ca89 in main /benchmark/bin/binutils-2.45/ld/./ldmain.c:882:3
#14 0x7f53fe884082 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x24082)
SUMMARY: AddressSanitizer: heap-buffer-overflow
/src/llvm-project/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp:26:3
in __asan_memset
Shadow bytes around the buggy address:
0x0c427fffd1c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fffd1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fffd1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fffd1f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c427fffd200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c427fffd210: 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa
0x0c427fffd220: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fffd230: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fffd240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fffd250: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c427fffd260: 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
==139062==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.