Bug 28162 - Segment fault on `objdump -S`
Summary: Segment fault on `objdump -S`
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.38
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-02 10:04 UTC by Shaohua Li
Modified: 2021-08-04 14:04 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
poc (1.56 KB, application/octet-stream)
2021-08-02 10:04 UTC, Shaohua Li
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shaohua Li 2021-08-02 10:04:45 UTC
Created attachment 13573 [details]
poc

Hi there,

I crashed `objdump -S` with a fuzzer.

- binutils version: 2.38(Head), commit af51804103a08cd1e12edc4f4a30eec2c5c4f9e8
- Compiler: clang12
- Platform: Ubuntu 18.04.5 LTS, x86_64
- Reproduce: run `objdump -S poc`


AddressSanitizer report:
=================================================================
==146==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000c8 (pc 0x000000ec4f53 bp 0x7fff30797a50 sp 0x7fff30797a30 T0)
==146==The signal is caused by a READ memory access.
==146==Hint: address points to the zero page.
    #0 0xec4f53 in bfd_get_symcount /binutils_latest/repo/bfd/./bfd.h:6842:16
    #1 0xec4c85 in mips_elf_assign_gp /binutils_latest/repo/bfd/elf32-mips.c:1679:11
    #2 0xec40d0 in mips_elf_final_gp /binutils_latest/repo/bfd/elf32-mips.c:1741:17
    #3 0xec3b2f in _bfd_mips_elf32_gprel16_reloc /binutils_latest/repo/bfd/elf32-mips.c:1789:9
    #4 0x1b49a57 in bfd_perform_relocation /binutils_latest/repo/bfd/reloc.c:711:14
    #5 0x1015559 in _bfd_elf_mips_get_relocated_section_contents /binutils_latest/repo/bfd/elfxx-mips.c:13362:10
    #6 0xae653f in bfd_get_relocated_section_contents /binutils_latest/repo/bfd/bfd.c:2166:10
    #7 0xb0fe68 in bfd_simple_get_relocated_section_contents /binutils_latest/repo/bfd/simple.c:298:14
    #8 0xcab59c in read_section /binutils_latest/repo/bfd/./dwarf2.c:582:7
    #9 0xca8237 in _bfd_dwarf2_slurp_debug_info /binutils_latest/repo/bfd/./dwarf2.c:4737:13
    #10 0xcac7c1 in _bfd_dwarf2_find_nearest_line /binutils_latest/repo/bfd/./dwarf2.c:4985:9
    #11 0x1013734 in _bfd_mips_elf_find_nearest_line /binutils_latest/repo/bfd/elfxx-mips.c:13061:7
    #12 0x4e496a in show_line /binutils_latest/repo/binutils/./objdump.c:1784:9
    #13 0x4e0b1f in disassemble_bytes /binutils_latest/repo/binutils/./objdump.c:2770:6
    #14 0x4dae9a in disassemble_section /binutils_latest/repo/binutils/./objdump.c:3455:4
    #15 0xb0e04a in bfd_map_over_sections /binutils_latest/repo/bfd/section.c:1383:5
    #16 0x4d1ae0 in disassemble_data /binutils_latest/repo/binutils/./objdump.c:3599:3
    #17 0x4cda84 in dump_bfd /binutils_latest/repo/binutils/./objdump.c:5006:5
    #18 0x4ccb9f in display_object_bfd /binutils_latest/repo/binutils/./objdump.c:5068:7
    #19 0x4ccaa9 in display_any_bfd /binutils_latest/repo/binutils/./objdump.c:5158:5
    #20 0x4cc65c in display_file /binutils_latest/repo/binutils/./objdump.c:5179:3
    #21 0x4cb063 in main /binutils_latest/repo/binutils/./objdump.c:5529:6
    #22 0x7f96145630b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #23 0x41c61d in _start (/out_bin/objdump+0x41c61d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /binutils_latest/repo/bfd/./bfd.h:6842:16 in bfd_get_symcount
==146==ABORTING
Comment 1 Alan Modra 2021-08-04 14:04:56 UTC
Fixed with commit 0613c3306cc7