https://sourceware.org/bugzilla/show_bug.cgi?id=33464
Bug ID: 33464 Summary: [BUG] A heap-buffer-overflow in _bfd_elf_parse_eh_frame at elf-eh-frame.c:756 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 16358 --> https://sourceware.org/bugzilla/attachment.cgi?id=16358&action=edit POC ## Description - Version: Binutils 2.45 with patches in bug 33451, bug 33455, and bug 33457. - 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 ==144772==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000002f8 at pc 0x00000042fe89 bp 0x7ffc9d116ef0 sp 0x7ffc9d1166b0 READ of size 16 at 0x6030000002f8 thread T0 #0 0x42fe88 in strlen /src/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:372:5 #1 0x7ae4cd in _bfd_elf_parse_eh_frame /benchmark/bin/binutils-2.45/bfd/elf-eh-frame.c:756:4 #2 0x786e7c in bfd_elf_discard_info /benchmark/bin/binutils-2.45/bfd/elflink.c:15228:4 #3 0x570be0 in gldelf_x86_64_after_allocation /benchmark/bin/binutils-2.45/ld/eelf_x86_64.c:179:21 #4 0x554ab7 in ldemul_after_allocation /benchmark/bin/binutils-2.45/ld/ldemul.c:98:3 #5 0x50d017 in lang_process /benchmark/bin/binutils-2.45/ld/ldlang.c:8642:3 #6 0x53ca89 in main /benchmark/bin/binutils-2.45/ld/./ldmain.c:882:3 #7 0x7f417accf082 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) 0x6030000002f8 is located 0 bytes to the right of 24-byte region [0x6030000002e0,0x6030000002f8) allocated by thread T0 here: #0 0x49917d in malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3 #1 0x5dcf72 in bfd_malloc /benchmark/bin/binutils-2.45/bfd/libbfd.c:291:9 #2 0x5c9c41 in bfd_get_full_section_contents /benchmark/bin/binutils-2.45/bfd/compress.c:742:21 #3 0x6f6cc6 in elf_mmap_section_contents /benchmark/bin/binutils-2.45/bfd/elf.c:14329:14 #4 0x6acef1 in _bfd_elf_mmap_section_contents /benchmark/bin/binutils-2.45/bfd/elf.c:14341:10 #5 0x7acec1 in _bfd_elf_parse_eh_frame /benchmark/bin/binutils-2.45/bfd/elf-eh-frame.c:624:3 #6 0x786e7c in bfd_elf_discard_info /benchmark/bin/binutils-2.45/bfd/elflink.c:15228:4 #7 0x570be0 in gldelf_x86_64_after_allocation /benchmark/bin/binutils-2.45/ld/eelf_x86_64.c:179:21 #8 0x554ab7 in ldemul_after_allocation /benchmark/bin/binutils-2.45/ld/ldemul.c:98:3 #9 0x50d017 in lang_process /benchmark/bin/binutils-2.45/ld/ldlang.c:8642:3 #10 0x53ca89 in main /benchmark/bin/binutils-2.45/ld/./ldmain.c:882:3 #11 0x7f417accf082 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/../sanitizer_common/sanitizer_common_interceptors.inc:372:5 in strlen Shadow bytes around the buggy address: 0x0c067fff8000: fa fa 00 00 00 03 fa fa 00 00 00 fa fa fa 00 00 0x0c067fff8010: 02 fa fa fa 00 00 00 fa fa fa 00 00 00 fa fa fa 0x0c067fff8020: 00 00 00 fa fa fa 00 00 00 fa fa fa 00 00 00 fa 0x0c067fff8030: fa fa 00 00 00 fa fa fa fd fd fd fa fa fa 00 00 0x0c067fff8040: 00 fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa =>0x0c067fff8050: 00 00 00 fa fa fa fd fd fd fa fa fa 00 00 00[fa] 0x0c067fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c067fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c067fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c067fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c067fff80a0: 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 ==144772==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.