bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/24688] New: Heap-buffer-overflow in bfd_hash_hash in hash.c in b


From: 15664243668 at 163 dot com
Subject: [Bug ld/24688] New: Heap-buffer-overflow in bfd_hash_hash in hash.c in bfd
Date: Mon, 17 Jun 2019 03:08:27 +0000

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

            Bug ID: 24688
           Summary: Heap-buffer-overflow in bfd_hash_hash in hash.c in bfd
           Product: binutils
           Version: 2.32
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: 15664243668 at 163 dot com
  Target Milestone: 2.32

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

Hi, 

A Heap-buffer-overflow problem was discovered in bfd_hash_hash in hash.c in
bfd, as distributed in binutils v2.32. A crafted ELF input can cause crash with
being executed by size in binutils v2.32 and I have confirmed them with address
sanitizer too.

Here are the POC files. Please use "size $POC" to reproduce the error.


ASAN dumps the backtrace as follow:

=================================================================
==3313==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4a038e0 at
pc 0x0809a7ef bp 0xffffcdc8 sp 0xffffcdb8
READ of size 1 at 0xf4a038e0 thread T0
    #0 0x809a7ee in bfd_hash_hash
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/hash.c:442
    #1 0x809a7ee in bfd_hash_lookup
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/hash.c:468
    #2 0x80ba7b6 in bfd_make_section_anyway_with_flags
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/section.c:1166
    #3 0x80ba7b6 in bfd_make_section_anyway
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/section.c:1213
    #4 0x819c3b9 in _bfd_elf_make_section_from_shdr
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/elf.c:1008
    #5 0x8197dbc in bfd_section_from_shdr
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/elf.c:2494
    #6 0x838f495 in bfd_elf32_object_p
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/elfcode.h:818
    #7 0x8094407 in bfd_check_format_matches
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/format.c:315
    #8 0x8053d8e in display_bfd
/home/zeroyu/experiment_without_cov/binutils-2.32/binutils/size.c:304
    #9 0x8053d8e in display_file
/home/zeroyu/experiment_without_cov/binutils-2.32/binutils/size.c:407
    #10 0x804f2ed in main
/home/zeroyu/experiment_without_cov/binutils-2.32/binutils/size.c:241
    #11 0xf78c6636 in __libc_start_main (/lib32/libc.so.6+0x18636)
    #12 0x805136b 
(/home/zeroyu/experiment_without_cov/binutilstest_with_asan_but_no_cov/bin/size+0x805136b)

0xf4a038e0 is located 0 bytes to the right of 4064-byte region
[0xf4a02900,0xf4a038e0)
allocated by thread T0 here:
    #0 0xf7afddee in malloc (/usr/lib32/libasan.so.2+0x96dee)
    #1 0x862ac99 in objalloc_create objalloc.c:95

SUMMARY: AddressSanitizer: heap-buffer-overflow
/home/zeroyu/experiment_without_cov/binutils-2.32/bfd/hash.c:442 bfd_hash_hash
Shadow bytes around the buggy address:
  0x3e9406c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x3e9406d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x3e9406e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x3e9406f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x3e940700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x3e940710: 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa
  0x3e940720: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x3e940730: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x3e940740: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x3e940750: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x3e940760: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==3313==ABORTING
[Inferior 1 (process 3313) exited with code 01]

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]