Bug 21311 - eu-elflint: heap-based buffer overflow in check_sysv_hash (elflint.c)
Summary: eu-elflint: heap-based buffer overflow in check_sysv_hash (elflint.c)
Status: RESOLVED FIXED
Alias: None
Product: elfutils
Classification: Unclassified
Component: tools (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-27 10:40 UTC by Agostino Sarubbo
Modified: 2018-08-17 04:09 UTC (History)
3 users (show)

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


Attachments
stacktrace (2.82 KB, text/plain)
2017-03-27 10:40 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo 2017-03-27 10:40:50 UTC
Created attachment 9945 [details]
stacktrace

Hoping that it has not the same root cause of bug 21310.

On elfutils-0.168:

# eu-elflint -d $FILE
READ of size 4 at 0x60b00000aff4 thread T0
    #0 0x40b36a in check_sysv_hash /tmp/portage/dev-libs/elfutils-0.168/work/elfutils-0.168/src/elflint.c:2020

Compiled with: gcc-6.3.0

Reproducer:
https://github.com/asarubbo/poc/blob/master/00235-elfutils-heapoverflow-check_sysv_hash

Stacktrace attached.
Comment 1 Mark Wielaard 2017-03-27 22:39:41 UTC
We were a little too trusting of the data we were checking.
https://sourceware.org/ml/elfutils-devel/2017-q1/msg00131.html
Comment 2 Mark Wielaard 2017-04-03 22:23:10 UTC
commit 61fe61898747f63eb35a81c2261f3590a3dab8fd
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Mar 28 00:38:52 2017 +0200

    elflint: Don't trust sh_entsize when checking hash sections.
    
    Calculate and use the expected entsize instead of relying on the one
    given by the ELF file section header. Return early if there isn't enough
    data in the section to check the full hash table.
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=21311
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>
Comment 3 Mark Wielaard 2017-04-03 22:31:15 UTC
Pushed