mainThe GNU Binary Utilities - Support: sr #109306, memory leaks in readelf

 
 

sr #109306: memory leaks in readelf

Submitter:  None
Submitted:  Mon 01 May 2017 04:29:48 PM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 01 May 2017 04:29:48 PM UTC, original submission:  

Hello,

I was fuzzing readelf and the address sanitizer detected a couple of memory
leaks during processing of corrupted files.  Normally I wouldn't care too much
about this  except that when you are fuzzing with the address sanitizer the
leaks stops the fuzzing and you can't continue fuzzing to find more
interesting bugs.

There are two leaks fixed by the attched path. The first is this:

==24362==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 536 byte(s) in 1 object(s) allocated from:
    #0 0x7f915a0a9e60 in malloc (/lib64/libasan.so.3+0xc6e60)
    #1 0x482132 in xmalloc xmalloc.c:148
    #2 0x4791fd in cmalloc /home/sgrubb/working/BUILD/binutils-2.28/binutils/dwarf.c:7450
    #3 0x43671d in get_dynamic_data /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:10776
    #4 0x437dd4 in process_symbol_table /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:11125
    #5 0x450281 in process_object /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17295
    #6 0x4514ba in process_file /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17684
    #7 0x4517da in main /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17758
    #8 0x7f9159c3d400 in __libc_start_main (/lib64/libc.so.6+0x20400)

This turns out to be a leak of gnubuckets. The second bug is in the following trace:

==499==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 166624 byte(s) in 1 object(s) allocated from:
    #0 0x7f7076d06e60 in malloc (/lib64/libasan.so.3+0xc6e60)
    #1 0x48217d in xmalloc xmalloc.c:148
    #2 0x479248 in cmalloc /home/sgrubb/working/BUILD/binutils-2.28/binutils/dwarf.c:7450
    #3 0x41be6f in get_64bit_elf_symbols /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:5415
    #4 0x4313de in process_dynamic_section /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:9314
    #5 0x4502a8 in process_object /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17295
    #6 0x451505 in process_file /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17690
    #7 0x451825 in main /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17764
    #8 0x7f707689a400 in __libc_start_main (/lib64/libc.so.6+0x20400)

This turns out to the leak of dynamic_symbols. There is a third memory leak
that I cannot fix because I just don't know the code well enough. Its in this
trace:

==8197==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 162656 byte(s) in 1 object(s) allocated from:
    #0 0x7f7b9ff46e60 in malloc (/lib64/libasan.so.3+0xc6e60)
    #1 0x4821e9 in xmalloc xmalloc.c:148
    #2 0x4792b4 in cmalloc /home/sgrubb/working/BUILD/binutils-2.28/binutils/dwarf.c:7450
    #3 0x41be95 in get_64bit_elf_symbols /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:5420
    #4 0x431404 in process_dynamic_section /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:9319
    #5 0x4502ec in process_object /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17304
    #6 0x451571 in process_file /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17702
    #7 0x451891 in main /home/sgrubb/working/BUILD/binutils-2.28/binutils/readelf.c:17776
    #8 0x7f7b9fada400 in __libc_start_main (/lib64/libc.so.6+0x20400)

No idea how to fix that leak. But it takes a while to hit it.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #40546:  binutils-2.28-mem-leaks.patch added by None (2KiB - text/x-patch - Patch attached fixing 2 of the 3 leaks.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-05-01 None Attached File- Added binutils-2.28-mem-leaks.patch, #40546

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code