public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/58937] New: Preloaded libasan segfaults on unsanitized executables
@ 2013-10-31 10:25 y.gribov at samsung dot com
  2013-10-31 11:37 ` [Bug sanitizer/58937] " y.gribov at samsung dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: y.gribov at samsung dot com @ 2013-10-31 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58937
           Summary: Preloaded libasan segfaults on unsanitized executables
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: y.gribov at samsung dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    e.gavrin at samsung dot com, jakub at gcc dot gnu.org,
                    kcc at gcc dot gnu.org

My system has a mix of sanitized and unsanitized executables and libs calling
each other in a complex manner. I've recently tried doing a global
LD_PRELOAD=libasan to make sure I don't have problems with initialization order
outlined in #56393.

I quickly ran into a problem which is reproduced in the attach. Here is the gdb
session log:
 $ /home/ygribov/install/gcc-master/bin/gcc -g main.i
 $ ./a.out
 $ LD_PRELOAD=~/install/gcc-master/lib64/libasan.so.0 ./a.out 
 Segmentation fault (core dumped)
 $ gdb a.out
 (gdb) set env LD_PRELOAD /home/ygribov/install/gcc-master/lib64/libasan.so.0
 (gdb) b __asan_init_v1
 (gdb) run
 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000000 in ?? ()
 (gdb) bt
 #0  0x0000000000000000 in ?? ()
 #1  0x00007ffff4e4fa62 in signal () at
/home/ygribov/gcc/gcc-master/libsanitizer/asan/asan_interceptors.cc:133
 #2  0x000000000040052c in main ()
 (gdb) fr 1
 #1  0x00007ffff4e4fa62 in signal () at
/home/ygribov/gcc/gcc-master/libsanitizer/asan/asan_interceptors.cc:133
 133        return REAL(signal)(signum, handler);
 (gdb) l
 128    #endif  // ASAN_INTERCEPT_PTHREAD_CREATE
 129    
 130    #if ASAN_INTERCEPT_SIGNAL_AND_SIGACTION
 131    INTERCEPTOR(void*, signal, int signum, void *handler) {
 132      if (!AsanInterceptsSignal(signum)) {
 133        return REAL(signal)(signum, handler);
 134      }
 135      return 0;
 136    }
 137    

It seems that current libasan currently relies on sanitized code to call
__asan_init. If we preload it into an unsanitized executable, it will remain
uninitialized and will segfault on every REAL(whatever) call.

IMHO ability to do global LD_PRELOAD for all executables in the system is
rather useful so I think it makes sense to support this usage scenario. What
about adding a ctor to call __asan_init in libasan itself?

Note that this error should repro in Clang (on platforms that use dynamic
linking).

-Y


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-08-28 14:44 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-31 10:25 [Bug sanitizer/58937] New: Preloaded libasan segfaults on unsanitized executables y.gribov at samsung dot com
2013-10-31 11:37 ` [Bug sanitizer/58937] " y.gribov at samsung dot com
2013-10-31 11:39 ` jakub at gcc dot gnu.org
2013-10-31 12:23 ` y.gribov at samsung dot com
2013-11-11 15:06 ` y.gribov at samsung dot com
2013-11-12  8:01 ` samsonov at google dot com
2013-11-12  8:16 ` kcc at gcc dot gnu.org
2013-11-12  8:45 ` y.gribov at samsung dot com
2013-11-12  8:52 ` eugeni.stepanov at gmail dot com
2013-11-13  8:49 ` y.gribov at samsung dot com
2013-11-13  9:53 ` eugeni.stepanov at gmail dot com
2013-11-14 10:48 ` y.gribov at samsung dot com
2013-11-14 10:50 ` y.gribov at samsung dot com
2013-11-15  8:53 ` eugeni.stepanov at gmail dot com
2014-01-22  6:37 ` y.gribov at samsung dot com
2014-01-23  7:54 ` y.gribov at samsung dot com
2014-04-07 15:10 ` y.gribov at samsung dot com
2014-08-28 14:44 ` y.gribov at samsung dot com

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).