[PATCH] [msan] intercept dlopen and clear shadow for it

Evgeniy Stepanov eugenis at google.com
Mon Mar 11 02:07:04 PDT 2013



================
Comment at: lib/msan/msan_linux.cc:34
@@ +33,3 @@
+// llvm/Support/Compiler.h defines away our interface.
+#undef __msan_unpoison
+
----------------
This is fragile. Future additions to Compiler.h can silently disable parts of MSan.
Please move UnpoisonMappedDSO to a new .cc file, so that this include does not affect anything else.

================
Comment at: lib/msan/msan_linux.cc:125
@@ +124,3 @@
+  // Compute the delta from the real base to get a relocation delta.
+  uptr delta = (uptr)base - preferred_base;
+  // Now we can figure out what the loader really mapped.
----------------
CHECK that base >= preferred_base.

================
Comment at: lib/msan/msan_linux.cc:134
@@ +133,3 @@
+      // mapping as defined.
+      seg_start = RoundDownTo(seg_start, GetPageSizeCached());
+      seg_end = RoundUpTo(seg_end, GetPageSizeCached());
----------------
Why is it needed? Could we just unpoison to the exact mapping limits?

================
Comment at: lib/msan/tests/CMakeLists.txt:104
@@ -98,2 +103,3 @@
                        DEPS ${MSAN_RUNTIME_LIBRARIES} ${ARGN}
+                       ${MSAN_LOADABLE_SO}
                        LINK_FLAGS ${MSAN_UNITTEST_LINK_FLAGS}
----------------
indentation++

================
Comment at: lib/msandr/msandr.cc:599
@@ +598,3 @@
+  // app segment base, which it has.  Alternatively, if we disable
+  // -mangle_app_seg and we won't need the swap.
+  bool need_swap = !dr_using_app_state(drcontext);
----------------
s/and/,/ ?

================
Comment at: lib/msandr/msandr.cc:650
@@ +649,3 @@
+        dr_printf("unpoisoning for dlopen: [%p-%p]\n", base, base + size);
+      __msan_unpoison(base, size);
+    }
----------------
Do we need to switch to app context here?
We use a plain memset for the same purpose above. Use either one or the other in both places, kill MEM_TO_SHADOW if it's not needed after that.


http://llvm-reviews.chandlerc.com/D509



More information about the llvm-commits mailing list