summaryrefslogtreecommitdiff
path: root/lib/msan/msan.cc
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-03-11 18:07:42 +0000
committerReid Kleckner <reid@kleckner.net>2013-03-11 18:07:42 +0000
commit0f92deb81207c80481ff0257fbaba640fe669633 (patch)
treed607657bc3c761a28ef7798195339f04fc8d837b /lib/msan/msan.cc
parentce700979f644c790c2d9d80f5cc2a1ada0380284 (diff)
[msan] intercept dlopen and clear shadow for it
Summary: The loader does not call mmap() through the PLT because it has to bootstrap the process before libc is present. Hooking dlopen() isn't enough either because the loader runs module initializers before returning, and they could run arbitrary msan instrumented code. If msandr is present, then we can intercept the mmaps from dlopen at the syscall layer and clear the shadow there. If msandr is missing, we clear the shadow after dlopen() and hope any initializers are trivial. Reviewers: eugenis CC: kcc, llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D509 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176818 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/msan.cc')
-rw-r--r--lib/msan/msan.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc
index cfa074182..96f99d4a8 100644
--- a/lib/msan/msan.cc
+++ b/lib/msan/msan.cc
@@ -59,6 +59,7 @@ static THREADLOCAL struct {
} __msan_stack_bounds;
static THREADLOCAL bool is_in_symbolizer;
+static THREADLOCAL bool is_in_loader;
extern "C" const int __msan_track_origins;
int __msan_get_track_origins() {
@@ -87,6 +88,14 @@ void EnterSymbolizer() { is_in_symbolizer = true; }
void ExitSymbolizer() { is_in_symbolizer = false; }
bool IsInSymbolizer() { return is_in_symbolizer; }
+void EnterLoader() { is_in_loader = true; }
+void ExitLoader() { is_in_loader = false; }
+
+extern "C" {
+SANITIZER_INTERFACE_ATTRIBUTE
+bool __msan_is_in_loader() { return is_in_loader; }
+}
+
static Flags msan_flags;
Flags *flags() {