Bug 21409 - objdump segfault - null pointer dereferencing
Summary: objdump segfault - null pointer dereferencing
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.28
: P2 normal
Target Milestone: 2.29
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-22 04:17 UTC by Manh-Dung Nguyen
Modified: 2021-08-25 16:35 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2017-04-23 00:00:00


Attachments
Crashing input (535 bytes, application/x-object)
2017-04-22 04:17 UTC, Manh-Dung Nguyen
Details
Another crashing input (769 bytes, application/x-archive)
2017-04-22 06:34 UTC, Manh-Dung Nguyen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Manh-Dung Nguyen 2017-04-22 04:17:59 UTC
Created attachment 10006 [details]
Crashing input

Dear All,

This bug was found with AFLGo, a directed version of AFL/AFLFast. Thanks also to Marcel Böhme and Van-Thuan Pham.

This bug was found on Ubuntu 14.04 64-bit & binutils was checked out from main repository at git://sourceware.org/git/binutils-gdb.git. Its commit is a6c21d4a553de184562fd8409a5bcd3f2cc2561a (Wed Apr 19 13:16:05 2017).

binutils was built with ASAN using gcc-6.2 and clang-3.4. The configure command was:

CC=clang CFLAGS="-DFORTIFY_SOURCE=2 -fstack-protector-all -fsanitize=undefined,address -fno-omit-frame-pointer -g -Wno-error" ../configure --disable-shared --disable-gdb --disable-libdecnumber --disable-readline --disable-sim

To reproduce:
Download the attached file - bug_7
objdump -SD bug_7

ASAN says:
==148394==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000010f21d7 bp 0x7ffe42ecf670 sp 0x7ffe42ece6c0 T0)
    #0 0x10f21d6 in _bfd_dwarf2_find_nearest_line /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/dwarf2.c:4212:9
    #1 0xd095d9 in _bfd_elf_find_nearest_line /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/elf.c:8642:7
    #2 0x511d79 in show_line /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:1486:9
    #3 0x506b94 in disassemble_bytes /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:1791:6
    #4 0x4f6b0a in disassemble_section /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:2304:7
    #5 0x9e4315 in bfd_map_over_sections /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/bfd/../../bfd/section.c:1395:5
    #6 0x4e4f50 in disassemble_data /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:2438:3
    #7 0x4d76be in dump_bfd /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3532:5
    #8 0x4d5fe8 in display_object_bfd /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3589:7
    #9 0x4d5dcc in display_any_bfd /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3678:5
    #10 0x4d45f3 in display_file /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:3699:3
    #11 0x4d26d3 in main /home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/../../binutils/objdump.c:4001:6
    #12 0x7fb407a88f44 in __libc_start_main /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:287
    #13 0x4cb13c in _start (/home/ubuntu/binutils-analysis/binutils-gdb/obj-asan/binutils/objdump+0x4cb13c)

VALGRIND says:
==148401== Invalid read of size 8
==148401==    at 0x4D209A: _bfd_dwarf2_find_nearest_line (dwarf2.c:4212)
==148401==    by 0x49B5EA: _bfd_elf_find_nearest_line (elf.c:8642)
==148401==    by 0x4050CC: show_line (objdump.c:1486)
==148401==    by 0x405B52: disassemble_bytes (objdump.c:1791)
==148401==    by 0x407248: disassemble_section (objdump.c:2304)
==148401==    by 0x469C57: bfd_map_over_sections (section.c:1395)
==148401==    by 0x40779C: disassemble_data (objdump.c:2438)
==148401==    by 0x409EA8: dump_bfd (objdump.c:3532)
==148401==    by 0x40A02E: display_object_bfd (objdump.c:3589)
==148401==    by 0x40A270: display_any_bfd (objdump.c:3678)
==148401==    by 0x40A2E4: display_file (objdump.c:3699)
==148401==    by 0x40ABB7: main (objdump.c:4001)
==148401==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==148401== 
==148401== 
==148401== Process terminating with default action of signal 11 (SIGSEGV)
==148401==  Access not within mapped region at address 0x0
==148401==    at 0x4D209A: _bfd_dwarf2_find_nearest_line (dwarf2.c:4212)
==148401==    by 0x49B5EA: _bfd_elf_find_nearest_line (elf.c:8642)
==148401==    by 0x4050CC: show_line (objdump.c:1486)
==148401==    by 0x405B52: disassemble_bytes (objdump.c:1791)
==148401==    by 0x407248: disassemble_section (objdump.c:2304)
==148401==    by 0x469C57: bfd_map_over_sections (section.c:1395)
==148401==    by 0x40779C: disassemble_data (objdump.c:2438)
==148401==    by 0x409EA8: dump_bfd (objdump.c:3532)
==148401==    by 0x40A02E: display_object_bfd (objdump.c:3589)
==148401==    by 0x40A270: display_any_bfd (objdump.c:3678)
==148401==    by 0x40A2E4: display_file (objdump.c:3699)
==148401==    by 0x40ABB7: main (objdump.c:4001)
Comment 1 Manh-Dung Nguyen 2017-04-22 06:34:44 UTC
Created attachment 10014 [details]
Another crashing input
Comment 2 Sourceware Commits 2017-04-23 11:53:51 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=97e83a100aa8250be783304bfe0429761c6e6b6b

commit 97e83a100aa8250be783304bfe0429761c6e6b6b
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Apr 23 13:55:49 2017 +0930

    PR 21409, segfault in _bfd_dwarf2_find_nearest_line
    
    	PR 21409
    	* dwarf2.c (_bfd_dwarf2_find_nearest_line): Don't segfault when
    	no symbols.
Comment 3 Alan Modra 2017-04-23 13:33:52 UTC
Fixed
Comment 4 Manh-Dung Nguyen 2017-05-02 01:35:17 UTC
Thanks Alan Modra. This is CVE-2017-8392.
Comment 5 ovile009988 2021-08-25 16:35:37 UTC Comment hidden (spam)