public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug general/24086] New: Multiple memory leak issues were discovered in in libelf and libdwelf
@ 2019-01-11  6:37 wcventure at 126 dot com
  2019-01-15 14:14 ` [Bug tools/24086] memory leak issues in eu-strip on invalid ELF file mark at klomp dot org
  2023-10-06 14:40 ` mark at klomp dot org
  0 siblings, 2 replies; 3+ messages in thread
From: wcventure at 126 dot com @ 2019-01-11  6:37 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=24086

            Bug ID: 24086
           Summary: Multiple memory leak issues were discovered in in
                    libelf and libdwelf
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: general
          Assignee: unassigned at sourceware dot org
          Reporter: wcventure at 126 dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Created attachment 11532
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11532&action=edit
POC

Hi there, 
We have discover lots of memory leak in libelf and libdwelf. Multiple memory
leak issues were discovered in libelf and libdwelf, as distributed in Elfutils
0.174. 
There are many heap allocations. But these heap allocations didn't deallocate
in the end. 

Please use the "./eu-strip $POC" to reproduce the bug.


The ASAN dumps the stack trace as follows:

> =================================================================
> ==22066==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 6712 byte(s) in 1 object(s) allocated from:
>     #0 0x7f3aeabb6d78 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded78)
>     #1 0x7f3aea8b5a38 in allocate_elf /home/wencheng/Experiment/elfutils/libelf/common.h:74
>     #2 0x7f3aea8b5a38 in elf_clone /home/wencheng/Experiment/elfutils/libelf/elf_clone.c:56
> 
> Direct leak of 96 byte(s) in 1 object(s) allocated from:
>     #0 0x7f3aeabb6d78 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded78)
>     #1 0x7f3aea39b1b2 in dwelf_strtab_init /home/wencheng/Experiment/elfutils/libdwelf/dwelf_strtab.c:94
>     #2 0x44406d in process_file /home/wencheng/Experiment/elfutils/src/strip.c:769
> 
> Indirect leak of 4080 byte(s) in 1 object(s) allocated from:
>     #0 0x7f3aeabb6b90 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb90)
>     #1 0x7f3aea39a787 in morememory /home/wencheng/Experiment/elfutils/libdwelf/dwelf_strtab.c:120
>     #2 0x7f3aea39a787 in newstring /home/wencheng/Experiment/elfutils/libdwelf/dwelf_strtab.c:161
>     #3 0x7f3aea39a787 in strtab_add /home/wencheng/Experiment/elfutils/libdwelf/dwelf_strtab.c:221
> 
> Indirect leak of 1120 byte(s) in 28 object(s) allocated from:
>     #0 0x7f3aeabb6d78 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded78)
>     #1 0x7f3aea82ab3e in elf_newscn /home/wencheng/Experiment/elfutils/libelf/elf_newscn.c:125
> 
> Indirect leak of 288 byte(s) in 1 object(s) allocated from:
>     #0 0x7f3aeabb6f80 in realloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdef80)
>     #1 0x7f3aea812223 in elf32_newphdr /home/wencheng/Experiment/elfutils/libelf/elf32_newphdr.c:134
> 
> Indirect leak of 240 byte(s) in 1 object(s) allocated from:
>     #0 0x7f3aeabb6b90 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb90)
>     #1 0x7f3aea39bd0c in dwelf_strtab_finalize /home/wencheng/Experiment/elfutils/libdwelf/dwelf_strtab.c:322
>     #2 0x7f3aea56c2bf  (/home/wencheng/Experiment/elfutils/build/lib/libdw.so.1+0x3852bf)
> 
> SUMMARY: AddressSanitizer: 12536 byte(s) leaked in 33 allocation(s).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tools/24086] memory leak issues in eu-strip on invalid ELF file
  2019-01-11  6:37 [Bug general/24086] New: Multiple memory leak issues were discovered in in libelf and libdwelf wcventure at 126 dot com
@ 2019-01-15 14:14 ` mark at klomp dot org
  2023-10-06 14:40 ` mark at klomp dot org
  1 sibling, 0 replies; 3+ messages in thread
From: mark at klomp dot org @ 2019-01-15 14:14 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=24086

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org
          Component|general                     |tools
            Summary|Multiple memory leak issues |memory leak issues in
                   |were discovered in in       |eu-strip on invalid ELF
                   |libelf and libdwelf         |file

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
This isn't a leak in any of the libraries. It is simply a "leak" when eu-strip
exits early when an invalid ELF file is encountered.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tools/24086] memory leak issues in eu-strip on invalid ELF file
  2019-01-11  6:37 [Bug general/24086] New: Multiple memory leak issues were discovered in in libelf and libdwelf wcventure at 126 dot com
  2019-01-15 14:14 ` [Bug tools/24086] memory leak issues in eu-strip on invalid ELF file mark at klomp dot org
@ 2023-10-06 14:40 ` mark at klomp dot org
  1 sibling, 0 replies; 3+ messages in thread
From: mark at klomp dot org @ 2023-10-06 14:40 UTC (permalink / raw)
  To: elfutils-devel

https://sourceware.org/bugzilla/show_bug.cgi?id=24086

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
It doesn't fix all "leaks" on errors, but it does resolve this particular one:

commit 557aa6a4b7b1d678b7c2c3b9aae1dafcc2160c64
Author: Mark Wielaard <mark@klomp.org>
Date:   Fri Oct 6 16:25:56 2023 +0200

    strip: Clean up a bit more after errors

    In some cases (late) errors would exit early without cleanup.  Set
    result to 1 (failure) in those cases and fallthrough.  That way we
    cleanup and might provide more hints to the user about what was wrong
    with the file.

         * src/strip.c (handle_elf): Set result to 1 and fallthrough
         instead of return 1.

    Signed-off-by: Mark Wielaard <mark@klomp.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-06 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11  6:37 [Bug general/24086] New: Multiple memory leak issues were discovered in in libelf and libdwelf wcventure at 126 dot com
2019-01-15 14:14 ` [Bug tools/24086] memory leak issues in eu-strip on invalid ELF file mark at klomp dot org
2023-10-06 14:40 ` mark at klomp dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).