public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/55739] asan doesn't work on common symbols
Date: Mon, 14 Jan 2013 22:12:00 -0000	[thread overview]
Message-ID: <bug-55739-4-mOlA2BTcxY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55739-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55739

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> 2013-01-14 22:11:16 UTC ---
Created attachment 29165
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29165
A prototype

If as, ld and ld.so provide size info via "symbol@size", we can do

.LASAN0:
# __beg:
    .quad    common_data
# __size:
    .quad    common_data@size
# __size_with_redzone:
    .quad    common_data@size + 40
# __name:
    .quad    .LC0
# __has_dynamic_init:
    .quad    0

[hjl@gnu-6 pr55739]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/../../release/usr/gcc-4.8.0/bin/gcc
-fsanitize=address -O -static-libasan   -c -o m.o m.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/../../release/usr/gcc-4.8.0/bin/gcc
-fsanitize=address -O -static-libasan   -c -o c.o c.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/../../release/usr/gcc-4.8.0/bin/gcc
-fsanitize=address -O -static-libasan -c size.S
/export/build/gnu/gcc/build-x86_64-linux/gcc/../../release/usr/gcc-4.8.0/bin/gcc
-fsanitize=address -O -static-libasan -o x m.o c.o size.o
./x
10: 0
29: 1
=================================================================
==1454== ERROR: AddressSanitizer: global-buffer-overflow on address
0x000002e70a18 at pc 0x401dc5 bp 0x7fffffffde90 sp 0x7fffffffde70
WRITE of size 4 at 0x000002e70a18 thread T0
    #0 0x401dc4 (/export/home/hjl/bugs/gcc/pr55739/x+0x401dc4)
0x000002e70a18 is located 0 bytes to the right of global variable 'c (d.c)'
(0x2e709a0) of size 120
  'c (d.c)' is ascii string ''
Shadow bytes around the buggy address:
  0x1000005ce0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x1000005ce140: 00 00 00[f9]f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x1000005ce150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000005ce190: 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
  Heap righ 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
  ASan internal:         fe
Stats: 0M malloced (0M for red zones) by 0 calls
Stats: 0M realloced by 0 calls
Stats: 0M freed by 0 calls
Stats: 0M really freed by 0 calls
Stats: 0M (0M-0M) mmaped; 0 maps, 0 unmaps
  mmaps   by size class: 
  mallocs by size class: 
  frees   by size class: 
  rfrees  by size class: 
Stats: malloc large: 0 small slow: 0
Stats: StackDepot: 0 ids; 0M mapped
==1454== ABORTING
make: *** [all] Error 1
[hjl@gnu-6 pr55739]$ readelf -s c.o | grep common_data
    17: 0000000000000020   120 OBJECT  GLOBAL DEFAULT  COM common_data
[hjl@gnu-6 pr55739]$


  parent reply	other threads:[~2013-01-14 22:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19 13:20 [Bug sanitizer/55739] New: " hjl.tools at gmail dot com
2012-12-19 13:26 ` [Bug sanitizer/55739] " jakub at gcc dot gnu.org
2012-12-19 13:42 ` hjl.tools at gmail dot com
2012-12-19 13:50 ` jakub at gcc dot gnu.org
2012-12-19 16:58 ` hjl.tools at gmail dot com
2012-12-21  9:47 ` kcc at gcc dot gnu.org
2013-01-14 22:12 ` hjl.tools at gmail dot com [this message]
2013-01-15  2:20 ` hjl.tools at gmail dot com
2013-01-17 16:41 ` hjl.tools at gmail dot com
2013-01-17 16:44 ` pinskia at gcc dot gnu.org
2013-01-17 16:49 ` hjl.tools at gmail dot com
2013-01-17 16:50 ` jakub at gcc dot gnu.org
2013-01-17 16:57 ` hjl.tools at gmail dot com
2013-01-17 17:49 ` jakub at gcc dot gnu.org
2021-08-07 23:12 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55739-4-mOlA2BTcxY@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).