https://sourceware.org/bugzilla/show_bug.cgi?id=27854
Bug ID: 27854 Summary: heap-buffer-overflow on objdump -D Product: binutils Version: 2.37 (HEAD) Status: UNCONFIRMED Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- Created attachment 13441 --> https://sourceware.org/bugzilla/attachment.cgi?id=13441&action=edit poc Hi there, I found a heap-buffer-overflow with AddressSanitizer (with compile flag -fsanitize=address) in `objdump -D`. However, the poc won't crash normally compiled binaries. I have attached the poc that triggered the heap-buffer-overflow. Compiler: gcc11 Reproduce: `objdump -D poc` AddressSanitizer output: ==67162==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61b0000015f9 at pc 0x0000006ce596 bp 0x7ffc1b9cd070 sp 0x7ffc1b9cd068 READ of size 1 at 0x61b0000015f9 thread T0 #0 0x6ce595 in _print_instrs /data/clean/binutils-gdb-asan/opcodes/nfp-dis.c:2841:25 #1 0x6ce595 in print_insn_nfp /data/clean/binutils-gdb-asan/opcodes/nfp-dis.c:2959:9 #2 0x4d7b75 in disassemble_bytes /data/clean/binutils-gdb-asan/binutils/./objdump.c:2814:20 #3 0x4d7b75 in disassemble_section /data/clean/binutils-gdb-asan/binutils/./objdump.c:3396:4 #4 0x84694b in bfd_map_over_sections /data/clean/binutils-gdb-asan/bfd/section.c:1377:5 #5 0x4cd111 in disassemble_data /data/clean/binutils-gdb-asan/binutils/./objdump.c:3540:3 #6 0x4cd111 in dump_bfd /data/clean/binutils-gdb-asan/binutils/./objdump.c:4939:5 #7 0x4cab03 in display_object_bfd /data/clean/binutils-gdb-asan/binutils/./objdump.c #8 0x4cab03 in display_any_bfd /data/clean/binutils-gdb-asan/binutils/./objdump.c:5091:5 #9 0x4c9fb1 in display_file /data/clean/binutils-gdb-asan/binutils/./objdump.c:5112:3 #10 0x4c9fb1 in main /data/clean/binutils-gdb-asan/binutils/./objdump.c:5462:6 #11 0x7fb4e46df0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16 #12 0x41c57d in _start (/data/clean/binutils-gdb-asan/binutils/objdump+0x41c57d) 0x61b0000015f9 is located 3961 bytes to the right of 1536-byte region [0x61b000000080,0x61b000000680) allocated by thread T0 here: #0 0x497952 in calloc (/data/clean/binutils-gdb-asan/binutils/objdump+0x497952) #1 0x6cafe7 in init_nfp_priv /data/clean/binutils-gdb-asan/opcodes/nfp-dis.c:2768:10 #2 0x6cafe7 in _print_instrs /data/clean/binutils-gdb-asan/opcodes/nfp-dis.c:2795:25 #3 0x6cafe7 in print_insn_nfp /data/clean/binutils-gdb-asan/opcodes/nfp-dis.c:2959:9 #4 0x4d7b75 in disassemble_bytes /data/clean/binutils-gdb-asan/binutils/./objdump.c:2814:20 #5 0x4d7b75 in disassemble_section /data/clean/binutils-gdb-asan/binutils/./objdump.c:3396:4 #6 0x84694b in bfd_map_over_sections /data/clean/binutils-gdb-asan/bfd/section.c:1377:5 SUMMARY: AddressSanitizer: heap-buffer-overflow /data/clean/binutils-gdb-asan/opcodes/nfp-dis.c:2841:25 in _print_instrs Shadow bytes around the buggy address: 0x0c367fff8260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff8270: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff8280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff8290: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff82a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0c367fff82b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa[fa] 0x0c367fff82c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff82d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff82e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff82f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c367fff8300: 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 ==67162==ABORTING -- You are receiving this mail because: You are on the CC list for the bug.