[compiler-rt] r258339 - [MSan] Clear parameters shadow before invoking malloc/free hooks.

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 20 11:56:05 PST 2016


Author: samsonov
Date: Wed Jan 20 13:56:04 2016
New Revision: 258339

URL: http://llvm.org/viewvc/llvm-project?rev=258339&view=rev
Log:
[MSan] Clear parameters shadow before invoking malloc/free hooks.

MSan runtime is not itself instrumented, so we need to explicitly
clear shadow for function arguments before calling user-provided
functions from runtime (e.g. we already do this for several
interceptors).

I'm still crafting a test case that would demonstrate this issue
reliably, and will commit it later today.

Modified:
    compiler-rt/trunk/lib/msan/msan.h

Modified: compiler-rt/trunk/lib/msan/msan.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=258339&r1=258338&r2=258339&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.h (original)
+++ compiler-rt/trunk/lib/msan/msan.h Wed Jan 20 13:56:04 2016
@@ -309,9 +309,15 @@ void MsanTSDDtor(void *tsd);
 
 }  // namespace __msan
 
-#define MSAN_MALLOC_HOOK(ptr, size) \
-  if (&__sanitizer_malloc_hook) __sanitizer_malloc_hook(ptr, size)
-#define MSAN_FREE_HOOK(ptr) \
-  if (&__sanitizer_free_hook) __sanitizer_free_hook(ptr)
+#define MSAN_MALLOC_HOOK(ptr, size)     \
+  if (&__sanitizer_malloc_hook) {       \
+    UnpoisonParam(2);                   \
+    __sanitizer_malloc_hook(ptr, size); \
+  }
+#define MSAN_FREE_HOOK(ptr)     \
+  if (&__sanitizer_free_hook) { \
+    UnpoisonParam(1);           \
+    __sanitizer_free_hook(ptr); \
+  }
 
 #endif  // MSAN_H




More information about the llvm-commits mailing list