[compiler-rt] 6ae7fc0 - [compiler-rt] check max address from kernel is <= mmap range size

Emily Shi via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 12:02:55 PDT 2021


Author: Emily Shi
Date: 2021-04-21T12:02:48-07:00
New Revision: 6ae7fc0a299c40c68b41b113561df03aa814412d

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

LOG: [compiler-rt] check max address from kernel is <= mmap range size

If these sizes do not match, asan will not work as expected. Previously, we added compile-time checks for non-iOS platforms. We check at run time for iOS because we get the max VM size from the kernel at run time.

rdar://76477969

Reviewed By: delcypher

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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 31d01b46fd6ec..f4c6b442a14a3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -1185,7 +1185,9 @@ static uptr GetTaskInfoMaxAddress() {
 uptr GetMaxUserVirtualAddress() {
   static uptr max_vm = GetTaskInfoMaxAddress();
   if (max_vm != 0) {
-    return max_vm - 1;
+    const uptr ret_value = max_vm - 1;
+    CHECK_LE(ret_value, SANITIZER_MMAP_RANGE_SIZE);
+    return ret_value;
   }
 
   // xnu cannot provide vm address limit


        


More information about the llvm-commits mailing list