Bug 21142 - readelf segfault - invalid read of size 8
Summary: readelf segfault - invalid read of size 8
Status: RESOLVED DUPLICATE of bug 21139
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.29
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-13 09:40 UTC by Thuan Pham
Modified: 2017-02-13 14:08 UTC (History)
1 user (show)

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


Attachments
Crashing input (1.28 KB, application/x-object)
2017-02-13 09:40 UTC, Thuan Pham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thuan Pham 2017-02-13 09:40:16 UTC
Created attachment 9809 [details]
Crashing input

Dear all,

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

This bug was found on Ubuntu 14.04 64-bit & binutils was checkout from main repository at git://sourceware.org/git/binutils-gdb.git. Its commit is 53f7e8ea7fad1fcff1b58f4cbd74e192e0bcbc1d (Fri Feb 10 00:00:16 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_8 
readelf -R6 bug_8


Valgrind says:
Hex dump of section '.debug_info':
readelf: Error: Section .symtab has an invalid sh_size of 0xe3000210
readelf: Warning: unable to apply unsupported reloc type 2 to section .debug_info
==142143== Invalid read of size 8
==142143==    at 0x408B73: target_specific_reloc_handling (readelf.c:11638)
==142143==    by 0x408B73: apply_relocations (readelf.c:12343)
==142143==    by 0x40EAC6: dump_section_as_bytes (readelf.c:12744)
==142143==    by 0x42334D: process_section_contents (readelf.c:13085)
==142143==    by 0x42334D: process_object (readelf.c:16780)
==142143==    by 0x402111: process_file (readelf.c:17154)
==142143==    by 0x402111: main (readelf.c:17225)
==142143==  Address 0x40 is not stack'd, malloc'd or (recently) free'd
==142143== 
==142143== 
==142143== Process terminating with default action of signal 11 (SIGSEGV)
==142143==  Access not within mapped region at address 0x40
==142143==    at 0x408B73: target_specific_reloc_handling (readelf.c:11638)
==142143==    by 0x408B73: apply_relocations (readelf.c:12343)
==142143==    by 0x40EAC6: dump_section_as_bytes (readelf.c:12744)
==142143==    by 0x42334D: process_section_contents (readelf.c:13085)
==142143==    by 0x42334D: process_object (readelf.c:16780)
==142143==    by 0x402111: process_file (readelf.c:17154)
==142143==    by 0x402111: main (readelf.c:17225)
==142143==  If you believe this happened as a result of a stack
==142143==  overflow in your program's main thread (unlikely but
==142143==  possible), you can try to increase the size of the
==142143==  main thread stack using the --main-stacksize= flag.
==142143==  The main thread stack size used in this run was 8388608.

ASAN says:
==136663==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000040 (pc 0x00000054a93e sp 0x7ffc654cd420 bp 0x7ffc654cd8f0 T0)
    #0 0x54a93d in target_specific_reloc_handling /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:11637
    #1 0x52e6dc in apply_relocations /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:12343
    #2 0x55de03 in dump_section_as_bytes /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:12744
    #3 0x4e1531 in process_section_contents /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:13085
    #4 0x48d610 in process_object /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:16780
    #5 0x488365 in process_file /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:17154
    #6 0x4855c3 in main /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:17225
    #7 0x7fca89589f44 (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
    #8 0x47ddfc in _start (/home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/readelf+0x47ddfc)
Comment 1 Nick Clifton 2017-02-13 14:08:25 UTC
Another duplicate bug.

*** This bug has been marked as a duplicate of bug 21139 ***