[compiler-rt] r210027 - [ASan Win] Fix memset interception in DLLs

Timur Iskhodzhanov timurrrr at google.com
Mon Jun 2 06:23:42 PDT 2014


Author: timurrrr
Date: Mon Jun  2 08:23:42 2014
New Revision: 210027

URL: http://llvm.org/viewvc/llvm-project?rev=210027&view=rev
Log:
[ASan Win] Fix memset interception in DLLs

Added:
    compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memchr.cc
Modified:
    compiler-rt/trunk/lib/interception/interception_win.cc

Modified: compiler-rt/trunk/lib/interception/interception_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_win.cc?rev=210027&r1=210026&r2=210027&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_win.cc (original)
+++ compiler-rt/trunk/lib/interception/interception_win.cc Mon Jun  2 08:23:42 2014
@@ -121,6 +121,7 @@ static size_t RoundUpToInstrBoundary(siz
     }
     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]

Added: compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memchr.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memchr.cc?rev=210027&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memchr.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memchr.cc Mon Jun  2 08:23:42 2014
@@ -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;
+}





More information about the llvm-commits mailing list