[llvm-branch-commits] [compiler-rt] b11d778 - Revert "Revert "[sanitizer] Add CHECKs to validate calculated TLS range" (#10…"

Vitaly Buka via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 11 07:58:02 PDT 2024


Author: Vitaly Buka
Date: 2024-09-11T07:57:34-07:00
New Revision: b11d7789581ff6694177f6b636dcf614815516b3

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

LOG: Revert "Revert "[sanitizer] Add CHECKs to validate calculated TLS range" (#10…"

This reverts commit 5804193e38680683b370cb3ced46c018d4dbd1b2.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
index 666e6f3b351067..a1107ff7d24737 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
@@ -151,6 +151,10 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
     // This may happen inside the DTOR of main thread, so just ignore it.
     tls_size = 0;
   }
+  if (tls_size) {
+    CHECK_LE(tls_beg, reinterpret_cast<uptr>(res));
+    CHECK_LT(reinterpret_cast<uptr>(res), tls_beg + tls_size);
+  }
   dtv->beg = tls_beg;
   dtv->size = tls_size;
   return dtv;


        


More information about the llvm-branch-commits mailing list