Bug 21877 - Memory leak in demangle
Summary: Memory leak in demangle
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.30
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-01 19:50 UTC by Google-Autofuzz
Modified: 2018-05-09 08:29 UTC (History)
1 user (show)

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


Attachments
binutils docker file (1.28 KB, text/plain)
2017-08-01 19:50 UTC, Google-Autofuzz
Details
Demangle PoC (18 bytes, text/plain)
2017-08-01 19:50 UTC, Google-Autofuzz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Google-Autofuzz 2017-08-01 19:50:25 UTC
Created attachment 10299 [details]
binutils docker file

Hello binutils team,
 
As part of our fuzzing efforts at Google, we have identified an issue affecting binutils (tested with master branch, 6dc8d7579d1857460 commit).  To reproduce we are attaching a dockerfile to help compiling the project with the LLVM taking advantage of the sanitizers that it offers.
 
Attached is a dockerfile that can be used for reproduction.  More information about how to use the dockerfile can be found here:  https://docs.docker.com/engine/reference/builder/
TL;DR instructions:
mkdir binutils
cp Dockerfile /path/to/binutils
docker build --no-cache /path/to/binutils
docker run -it <image id>
(from another terminal, outside the container):
docker cp /path/to/attached/reproducer <container id>:/fuzzing/
https://docs.docker.com/engine/reference/commandline/cp/
(back inside the container) /fuzzing/repro.sh /fuzzing/reproducer
 
Alternatively, and depending on the bug, you could use gcc, valgrind or other instrumentation tools to aid in the investigation.
 
The sanitizer error that we encountered is here:
 
==38==ERROR: LeakSanitizer: detected memory leaks
 
Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x4d5c48 in malloc (/fuzzing/binutils-gdb/build/demangle_fuzzer+0x4d5c48)
    #1 0x536e39 in xmalloc /fuzzing/binutils-gdb/libiberty/xmalloc.c:147:12
    #2 0x51783e in demangle_template /fuzzing/binutils-gdb/libiberty/cplus-dem.c:2228:27
    #3 0x515fcd in demangle_signature /fuzzing/binutils-gdb/libiberty/cplus-dem.c:1691:18
    #4 0x5138e0 in internal_cplus_demangle /fuzzing/binutils-gdb/libiberty/cplus-dem.c:1257:14
    #5 0x51265c in cplus_demangle /fuzzing/binutils-gdb/libiberty/cplus-dem.c:918:9
    #6 0x51013d in LLVMFuzzerTestOneInput /fuzzing/binutils-gdb/build/../libiberty/demangle_fuzzer.cc:11:20
    #7 0x53f66c in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/binutils-gdb/build/demangle_fuzzer+0x53f66c)
 
Indirect leak of 3 byte(s) in 3 object(s) allocated from:
    #0 0x4d5c48 in malloc (/fuzzing/binutils-gdb/build/demangle_fuzzer+0x4d5c48)
    #1 0x536e39 in xmalloc /fuzzing/binutils-gdb/libiberty/xmalloc.c:147:12
    #2 0x517d9b in demangle_template /fuzzing/binutils-gdb/libiberty/cplus-dem.c:2327:31
    #3 0x515fcd in demangle_signature /fuzzing/binutils-gdb/libiberty/cplus-dem.c:1691:18
    #4 0x5138e0 in internal_cplus_demangle /fuzzing/binutils-gdb/libiberty/cplus-dem.c:1257:14
    #5 0x51265c in cplus_demangle /fuzzing/binutils-gdb/libiberty/cplus-dem.c:918:9
    #6 0x51013d in LLVMFuzzerTestOneInput /fuzzing/binutils-gdb/build/../libiberty/demangle_fuzzer.cc:11:20
    #7 0x53f66c in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/fuzzing/binutils-gdb/build/demangle_fuzzer+0x53f66c)
 
SUMMARY: AddressSanitizer: 27 byte(s) leaked in 4 allocation(s). 
 
We will gladly work with you so you can successfully confirm and reproduce this issue. Do let us know if you have any feedback surrounding the documentation.
 
Once you have reproduced the issue, we’d appreciate to learn your expected timeline for an update to be released. With any fix, please attribute the report to “Google Autofuzz project”.
 
We are also pleased to inform you that your project is eligible for inclusion to the OSS-Fuzz project, which can provide additional continuous fuzzing, and encourage you to investigate integration options.
 
Don’t hesitate to let us know if you have any questions!
 
Google AutoFuzz Team
Comment 1 Google-Autofuzz 2017-08-01 19:50:57 UTC
Created attachment 10300 [details]
Demangle PoC
Comment 2 Google-Autofuzz 2017-08-02 00:37:45 UTC
Resolving in favor of reporting directly to GCC.
Comment 3 Google-Autofuzz 2017-08-03 23:18:25 UTC
GCC indicated that this was the proper component for our report since this only reproduces with binutils, apologies for the noise.
Comment 4 Alan Modra 2018-05-09 08:29:43 UTC
Not a binutils bug.  Really.