[llvm-branch-commits] [sanitizer] Fix intersecting stacks workaround (PR #108672)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 13 20:07:13 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

I don't have reproducers, and don't know if this
branch is even possible but it looks like a typo
in 031c40dc3c71e1e08d0c459b81fc6b54184cec58.

Before the patch:
For order "stk_begin, tls_begin, stk_end, tls_end", range [stk_end, tls_end) was discarded.
For order "stk_begin, tls_begin, tls_end, stk_end", range [stk_end, stk_end) was discarded.

After the patch:
For order "stk_begin, tls_begin, stk_end, tls_end", range [stk_end, tls_end) goes to tls.
For order "stk_begin, tls_begin, tls_end, stk_end", range [stk_end, stk_end) goes to tls.


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


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp (+1-1) 


``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index c3c717bbdbe4c9..579d163479858c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -642,7 +642,7 @@ void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
   if (!main) {
     // If stack and tls intersect, make them non-intersecting.
     if (*tls_addr > *stk_addr && *tls_addr < *stk_addr + *stk_size) {
-      if (*stk_addr + *stk_size < *tls_addr + *tls_size)
+      if (*stk_addr + *stk_size > *tls_addr + *tls_size)
         *tls_size = *stk_addr + *stk_size - *tls_addr;
       *stk_size = *tls_addr - *stk_addr;
     }

``````````

</details>


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


More information about the llvm-branch-commits mailing list