Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mknames crashes by default during the compile time #7

Closed
asarubbo opened this issue Nov 18, 2019 · 3 comments
Closed

mknames crashes by default during the compile time #7

asarubbo opened this issue Nov 18, 2019 · 3 comments

Comments

@asarubbo
Copy link

To reproduce it is enough to compile with -fsanitize=address:

echo '#include <elf.h>' | gcc -E -dM -xc /dev/stdin | ./mknames elfnames.c
=================================================================
==206==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000000d7 at pc 0x0000004325e9 bp 0x7fff066f4380 sp 0x7fff066f3b28
READ of size 9 at 0x6020000000d7 thread T0
    #0 0x4325e8 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) /var/tmp/portage/sys-libs/compiler-rt-sanitizers-9.0.0/work/compiler-rt-9.0.0.src/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:834:7
    #1 0x432b3a in bcmp /var/tmp/portage/sys-libs/compiler-rt-sanitizers-9.0.0/work/compiler-rt-9.0.0.src/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:880:10
    #2 0x4c2e8e in readdefine /var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames.c:197:7
    #3 0x4c2e8e in readinput /var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames.c:227:2
    #4 0x4c2e8e in main /var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames.c:363:5
    #5 0x7ff3011d1dca in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.29-r2/work/glibc-2.29/csu/../csu/libc-start.c:308:16
    #6 0x41b369 in _start (/var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames+0x41b369)

0x6020000000d7 is located 0 bytes to the right of 7-byte region [0x6020000000d0,0x6020000000d7)
allocated by thread T0 here:
    #0 0x49325d in malloc /var/tmp/portage/sys-libs/compiler-rt-sanitizers-9.0.0/work/compiler-rt-9.0.0.src/lib/asan/asan_malloc_linux.cc:145:3
    #1 0x4c2dc1 in readdefine /var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames.c:193:12
    #2 0x4c2dc1 in readinput /var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames.c:227:2
    #3 0x4c2dc1 in main /var/tmp/portage/dev-util/elfkickers-3.1/work/ELFkickers-3.1/elftoc/mknames.c:363:5
    #4 0x7ff3011d1dca in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.29-r2/work/glibc-2.29/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-buffer-overflow /var/tmp/portage/sys-libs/compiler-rt-sanitizers-9.0.0/work/compiler-rt-9.0.0.src/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:834:7 in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long)
Shadow bytes around the buggy address:
  0x0c047fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c047fff8000: fa fa 00 07 fa fa fd fd fa fa 00 07 fa fa fd fd
=>0x0c047fff8010: fa fa 00 06 fa fa 00 05 fa fa[07]fa fa fa fa fa
  0x0c047fff8020: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8060: 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  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
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==206==ABORTING
@BR903
Copy link
Owner

BR903 commented Nov 18, 2019

Good catch, should be fixed now.

@BR903 BR903 closed this as completed Nov 18, 2019
@asarubbo
Copy link
Author

I spotted it during the compilation via the Gentoo Package manager. If you can issue a minor release you will facilitate us. Thanks in advance.

@BR903
Copy link
Owner

BR903 commented Nov 18, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants