tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] AddressSanitizer: heap-buffer-overflow


From: Zhuo Zhang
Subject: [Tinycc-devel] AddressSanitizer: heap-buffer-overflow
Date: Thu, 11 Feb 2021 12:25:28 +0000

A heap-buffer overflow occurs in commit fbef90a7039b994907db34fde50f6fa5e46ab535 (ASAN on).

System info: ubuntu 18.04, x86-64


$ cat poc.c
a() {
  int b;
  asm("" : : ""(b == 0), ""(b));
}

$ ./tcc poc.c
=================================================================
==33065==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x625000000098 at pc 0x00000061a8bd bp 0x7ffdac9d2490 sp 0x7ffdac9d2488
READ of size 2 at 0x625000000098 thread T0
    #0 0x61a8bc  (/root/git/tinycc/tcc+0x61a8bc)
    #1 0x5e4588  (/root/git/tinycc/tcc+0x5e4588)
    #2 0x589d3a  (/root/git/tinycc/tcc+0x589d3a)
    #3 0x588c25  (/root/git/tinycc/tcc+0x588c25)
    #4 0x5afa26  (/root/git/tinycc/tcc+0x5afa26)
    #5 0x5abf86  (/root/git/tinycc/tcc+0x5abf86)
    #6 0x554412  (/root/git/tinycc/tcc+0x554412)
    #7 0x51b550  (/root/git/tinycc/tcc+0x51b550)
    #8 0x51d252  (/root/git/tinycc/tcc+0x51d252)
    #9 0x51697a  (/root/git/tinycc/tcc+0x51697a)
    #10 0x7f2b7dfd7b96 in __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:310
    #11 0x41a5d9 in pthread_getattr_np (/root/git/tinycc/tcc+0x41a5d9)

0x625000000098 is located 104 bytes to the left of 9296-byte region [0x625000000100,0x625000002550)
allocated by thread T0 here:
    #0 0x4da490 in malloc (/root/git/tinycc/tcc+0x4da490)
    #1 0x51879b  (/root/git/tinycc/tcc+0x51879b)
    #2 0x51b073  (/root/git/tinycc/tcc+0x51b073)
    #3 0x51d252  (/root/git/tinycc/tcc+0x51d252)
    #4 0x51697a  (/root/git/tinycc/tcc+0x51697a)
    #5 0x7f2b7dfd7b96 in __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:310

SUMMARY: AddressSanitizer: heap-buffer-overflow (/root/git/tinycc/tcc+0x61a8bc)
Shadow bytes around the buggy address:
  0x0c4a7fff7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c4a7fff8010: fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4a7fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a7fff8060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==33065==ABORTING




reply via email to

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