summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-06-02 13:23:42 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-06-02 13:23:42 +0000
commit51fadc387a6bbd9b9b6cb5adfb7c170110ecc154 (patch)
treef4ee98c2fd8abdb0e7e83ebe8e838f042c027db6 /compiler-rt
parent9ef622e5bf6467a4d5295fad1486956c4dcac22d (diff)
downloadbcm5719-llvm-51fadc387a6bbd9b9b6cb5adfb7c170110ecc154.tar.gz
bcm5719-llvm-51fadc387a6bbd9b9b6cb5adfb7c170110ecc154.zip
[ASan Win] Fix memset interception in DLLs
llvm-svn: 210027
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/interception/interception_win.cc1
-rw-r--r--compiler-rt/test/asan/TestCases/Windows/dll_intercept_memchr.cc21
2 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/lib/interception/interception_win.cc b/compiler-rt/lib/interception/interception_win.cc
index 332fc7112a4..fe47b627cc0 100644
--- a/compiler-rt/lib/interception/interception_win.cc
+++ b/compiler-rt/lib/interception/interception_win.cc
@@ -121,6 +121,7 @@ static size_t RoundUpToInstrBoundary(size_t size, char *code) {
}
switch (0x00FFFFFF & *(unsigned int*)(code + cursor)) {
case 0x24448A: // 8A 44 24 XX = mov eal, dword ptr [esp+XXh]
+ case 0x24448B: // 8B 44 24 XX = mov eax, dword ptr [esp+XXh]
case 0x244C8B: // 8B 4C 24 XX = mov ecx, dword ptr [esp+XXh]
case 0x24548B: // 8B 54 24 XX = mov edx, dword ptr [esp+XXh]
case 0x24748B: // 8B 74 24 XX = mov esi, dword ptr [esp+XXh]
diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memchr.cc b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memchr.cc
new file mode 100644
index 00000000000..1435bdc5012
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memchr.cc
@@ -0,0 +1,21 @@
+// RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t
+// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll
+// RUN: not %run %t %t.dll 2>&1 | FileCheck %s
+
+#include <string.h>
+
+extern "C" __declspec(dllexport)
+int test_function() {
+ char buff[6] = "Hello";
+
+ memchr(buff, 'z', 7);
+// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+// CHECK: READ of size 7 at [[ADDR]] thread T0
+// CHECK-NEXT: __asan_wrap_memchr
+// CHECK-NEXT: memchr
+// CHECK-NEXT: test_function {{.*}}dll_intercept_memchr.cc:[[@LINE-5]]
+// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
+// CHECK-NEXT: test_function {{.*}}dll_intercept_memchr.cc
+// CHECK: 'buff' <== Memory access at offset {{.*}} overflows this variable
+ return 0;
+}
OpenPOWER on IntegriCloud