Bug 21136 - readelf segfault - heap buffer overflow
Summary: readelf segfault - heap buffer overflow
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:03 UTC by Thuan Pham
Modified: 2017-02-13 16:55 UTC (History)
1 user (show)

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


Attachments
Crashing input (1.30 KB, application/x-object)
2017-02-13 09:03 UTC, Thuan Pham
Details
attachment-54452-0.html (774 bytes, text/html)
2017-02-13 15:35 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:03:40 UTC
Created attachment 9803 [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) 

To reproduce:
Download the attached file - bug_2
readelf -da bug_2

Valgrind says:
==29176== Invalid read of size 8
==29176==    at 0x408B77: target_specific_reloc_handling (readelf.c:11638)
==29176==    by 0x408B77: apply_relocations (readelf.c:12343)
==29176==    by 0x4178B4: process_notes_at.part.19 (readelf.c:16279)
==29176==    by 0x423D91: process_notes_at (readelf.c:16415)
==29176==    by 0x423D91: process_note_sections (readelf.c:16526)
==29176==    by 0x423D91: process_notes (readelf.c:16559)
==29176==    by 0x423D91: process_object (readelf.c:16782)
==29176==    by 0x402111: process_file (readelf.c:17154)
==29176==    by 0x402111: main (readelf.c:17225)
==29176==  Address 0x20052093a0 is not stack'd, malloc'd or (recently) free'd
==29176== 
==29176== 
==29176== Process terminating with default action of signal 11 (SIGSEGV)
==29176==  Access not within mapped region at address 0x20052093A0
==29176==    at 0x408B77: target_specific_reloc_handling (readelf.c:11638)
==29176==    by 0x408B77: apply_relocations (readelf.c:12343)
==29176==    by 0x4178B4: process_notes_at.part.19 (readelf.c:16279)
==29176==    by 0x423D91: process_notes_at (readelf.c:16415)
==29176==    by 0x423D91: process_note_sections (readelf.c:16526)
==29176==    by 0x423D91: process_notes (readelf.c:16559)
==29176==    by 0x423D91: process_object (readelf.c:16782)
==29176==    by 0x402111: process_file (readelf.c:17154)
==29176==    by 0x402111: main (readelf.c:17225)

ASAN says
==30126==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61900000ee00 at pc 0x54aa2e bp 0x7ffcee43fc30 sp 0x7ffcee43fc28
READ of size 8 at 0x61900000ee00 thread T0
    #0 0x54aa2d 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 0x527e5f in process_notes_at /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:16279
    #3 0x52616c in process_note_sections /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:16526
    #4 0x4e1ec2 in process_notes /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:16559
    #5 0x48d646 in process_object /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:16782
    #6 0x488365 in process_file /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:17154
    #7 0x4855c3 in main /home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/../../binutils/readelf.c:17225
    #8 0x7fef50e75f44 (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
    #9 0x47ddfc in _start (/home/ubuntu/thesis/subjects/binutils-newest/build-asan/binutils/readelf+0x47ddfc)
Comment 1 Thuan Pham 2017-02-13 10:15:18 UTC
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
Comment 2 Nick Clifton 2017-02-13 15:21:55 UTC
Another duplicate bug

*** This bug has been marked as a duplicate of bug 21137 ***
Comment 3 Thuan Pham 2017-02-13 15:35:19 UTC
Created attachment 9817 [details]
attachment-54452-0.html

Hi Nick,
Thank you for quickly fixing the bugs I reported. 21136 looks totally
different from 21137, both in call-stack and in crashing functions. I do
see that 21136 shares something in common with 21139; however, the stack
traces of these two reported bugs are also considerably different.
Regards,
Thuan

On Mon, Feb 13, 2017 at 11:21 PM, nickc at redhat dot com <
sourceware-bugzilla@sourceware.org> wrote:

> https://sourceware.org/bugzilla/show_bug.cgi?id=21136
>
> Nick Clifton <nickc at redhat dot com> changed:
>
>            What    |Removed                     |Added
> ------------------------------------------------------------
> ----------------
>              Status|UNCONFIRMED                 |RESOLVED
>                  CC|                            |nickc at redhat dot com
>          Resolution|---                         |DUPLICATE
>
> --- Comment #2 from Nick Clifton <nickc at redhat dot com> ---
> Another duplicate bug
>
> *** This bug has been marked as a duplicate of bug 21137 ***
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 4 Nick Clifton 2017-02-13 16:54:16 UTC
Hi Thuan,

> Thank you for quickly fixing the bugs I reported. 21136 looks totally
> different from 21137, both in call-stack and in crashing functions. I do
> see that 21136 shares something in common with 21139; however, the stack
> traces of these two reported bugs are also considerably different.
 
Sorry - that was my mistake.  I should have ibndi

*** This bug has been marked as a duplicate of bug 21139 ***
Comment 5 Nick Clifton 2017-02-13 16:55:45 UTC
> Sorry - that was my mistake.  I should have ibndi

[Doh - hit send before I was ready].

What I meant to say was that you were correct.  This bug is essentially a duplicate of 21139 not 21137.  I have updated the Status accordingly.

Cheers
  Nick