Bug 25364 - memory leak objdump
Summary: memory leak objdump
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-10 14:48 UTC by featherrain26
Modified: 2020-01-13 09:26 UTC (History)
0 users

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


Attachments
POC input (2.39 KB, application/x-sharedlib)
2020-01-11 12:47 UTC, featherrain26
Details

Note You need to log in before you can comment on or make changes to this bug.
Description featherrain26 2020-01-10 14:48:34 UTC

    
Comment 1 featherrain26 2020-01-11 12:46:05 UTC
Hi, there.

There is a memory leak in file binutils/nm.c, get_data function.

Here is the reproducing environment and procedure:

Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial
gcc:            5.4.0

compilation:
CFLAGS="-fsanitize=address,undefined" ./configure

./objdump -D poc

Here is the error message:

=================================================================
==78623==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4294967344 byte(s) in 1 object(s) allocated from:
    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x507d27 in bfd_malloc (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x507d27)
    #2 0x57c88a in _bfd_x86_elf_get_synthetic_symtab (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x57c88a)
    #3 0x71227f in elf_i386_get_synthetic_symtab (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x71227f)
    #4 0x41e501 in dump_bfd (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41e501)
    #5 0x41e926 in display_object_bfd (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41e926)
    #6 0x41eebf in display_any_bfd (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41eebf)
    #7 0x41ef36 in display_file (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41ef36)
    #8 0x4201a2 in main (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x4201a2)
    #9 0x7ffff5baf82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x507d27 in bfd_malloc (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x507d27)
    #2 0x7105ba in elf_i386_get_synthetic_symtab (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x7105ba)
    #3 0x41e501 in dump_bfd (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41e501)
    #4 0x41e926 in display_object_bfd (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41e926)
    #5 0x41eebf in display_any_bfd (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41eebf)
    #6 0x41ef36 in display_file (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x41ef36)
    #7 0x4201a2 in main (/playground/playground/binutils-2.32-r/binutils-2.32/binutils/objdump+0x4201a2)
    #8 0x7ffff5baf82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: 4294967392 byte(s) leaked in 2 allocation(s).
Comment 2 featherrain26 2020-01-11 12:47:19 UTC
Created attachment 12185 [details]
POC input
Comment 3 Alan Modra 2020-01-13 09:26:29 UTC
Already fixed on 2.34