[compiler-rt] ad2be02 - ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1

Martin Liska via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 20 10:28:57 PDT 2020


Author: Martin Liska
Date: 2020-10-20T19:28:12+02:00
New Revision: ad2be02a833e56f7fe280797280b219eb3312621

URL: https://github.com/llvm/llvm-project/commit/ad2be02a833e56f7fe280797280b219eb3312621
DIFF: https://github.com/llvm/llvm-project/commit/ad2be02a833e56f7fe280797280b219eb3312621.diff

LOG: ASAN: Support detect_invalid_pointer_pairs=1 with detect_stack_use_after_return=1

Do not crash when AsanThread::GetStackVariableShadowStart does not find
a variable for a pointer on a shadow stack.

Differential Revision: https://reviews.llvm.org/D89552

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_thread.cpp
    compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-success.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp
index f0df8bd4b374..58cdc29d365a 100644
--- a/compiler-rt/lib/asan/asan_thread.cpp
+++ b/compiler-rt/lib/asan/asan_thread.cpp
@@ -366,7 +366,9 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) {
     bottom = stack_bottom();
   } else if (has_fake_stack()) {
     bottom = fake_stack()->AddrIsInFakeStack(addr);
-    CHECK(bottom);
+    if (bottom == 0) {
+      return 0;
+    }
   } else {
     return 0;
   }

diff  --git a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-success.cpp b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-success.cpp
index 7ea120ed5c70..79714c7b9005 100644
--- a/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-success.cpp
+++ b/compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-success.cpp
@@ -1,6 +1,7 @@
 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
 
 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2 %run %t
+// RUN: %env_asan_opts=detect_invalid_pointer_pairs=2,detect_stack_use_after_return=1 %run %t
 
 #include <assert.h>
 #include <stdlib.h>


        


More information about the llvm-commits mailing list