Created attachment 10385 [details] POC to trigger heap buffer overflow (objdump) After some fuzz testing I found a crashing test case. Version: 2.29 Command: objdump -x -Wl -R -SD objdump_hbo_elf_read_notes ASAN: ==10130==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000ef4f at pc 0x0000006e843d bp 0x7ffcd41d0ad0 sp 0x7ffcd41d0ac8 WRITE of size 1 at 0x60200000ef4f thread T0 #0 0x6e843c in elf_read_notes XYZ/binutils-2.29/bfd/elf.c:10991:13 #1 0x6e843c in bfd_section_from_phdr XYZ/binutils-2.29/bfd/elf.c:2983 #2 0x6cf1ea in bfd_elf64_core_file_p XYZ/binutils-2.29/bfd/./elfcore.h:277:11 #3 0x65bf6c in bfd_check_format_matches XYZ/binutils-2.29/bfd/format.c:311:14 #4 0x4e8f3a in display_object_bfd XYZ/binutils-2.29/binutils/./objdump.c:3621:7 #5 0x4e8f3a in display_any_bfd XYZ/binutils-2.29/binutils/./objdump.c:3692 #6 0x4e7d5a in display_file XYZ/binutils-2.29/binutils/./objdump.c:3713:3 #7 0x4e7d5a in main XYZ/binutils-2.29/binutils/./objdump.c:4015 #8 0x7fd0529a982f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) #9 0x419d98 in _start (XYZ/binutils-2.29/binutils/objdump+0x419d98) 0x60200000ef4f is located 1 bytes to the left of 1-byte region [0x60200000ef50,0x60200000ef51) allocated by thread T0 here: #0 0x4b85ac in malloc /home/llvm/clang-3.9/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64:3 #1 0x6618b3 in bfd_malloc XYZ/binutils-2.29/bfd/libbfd.c:193:9 SUMMARY: AddressSanitizer: heap-buffer-overflow XYZ/binutils-2.29/bfd/elf.c:10991:13 in elf_read_notes Shadow bytes around the buggy address: 0x0c047fff9d90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9dc0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9dd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c047fff9de0: fa fa fa fa fa fa fa fa fa[fa]01 fa fa fa 00 01 0x0c047fff9df0: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa fd fa 0x0c047fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9e20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c047fff9e30: 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 Heap right redzone: fb Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack partial redzone: f4 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 ==10130==ABORTING
The binutils-2_29-branch branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=30326b094b8fc2594c76cf4beab70965afa7a111 commit 30326b094b8fc2594c76cf4beab70965afa7a111 Author: Nick Clifton <nickc@redhat.com> Date: Fri Sep 1 10:17:00 2017 +0100 Check for an invalid note size when parsing ELF notes. PR 21933 PR 22060 * elf.c (elf_read_notes): Check for a note size of -1.
Hi Kamil, Thanks for reporting this bug. The problem had already been reported and fixed in PR 21933, but the patch had not been backported to the 2.29 branch. I have now taken care of this. Cheers Nick