[compiler-rt] Reland "[sanitizer] Add CHECKs to validate calculated TLS range" (PR #108122)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 17:46:57 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

Reverts llvm/llvm-project#<!-- -->108112

---
Full diff: https://github.com/llvm/llvm-project/pull/108122.diff


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp (+4) 


``````````diff
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;

``````````

</details>


https://github.com/llvm/llvm-project/pull/108122


More information about the llvm-commits mailing list