[compiler-rt] Poison last word of FakeFrame (PR #133687)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 31 00:47:13 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: None (brandb97)

<details>
<summary>Changes</summary>

Fixes [issue#<!-- -->122640](https://github.com/llvm/llvm-project/issues/133640)

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


1 Files Affected:

- (modified) compiler-rt/lib/asan/asan_fake_stack.cpp (+6-1) 


``````````diff
diff --git a/compiler-rt/lib/asan/asan_fake_stack.cpp b/compiler-rt/lib/asan/asan_fake_stack.cpp
index 7443ff166984d..9f1b3aa2c991e 100644
--- a/compiler-rt/lib/asan/asan_fake_stack.cpp
+++ b/compiler-rt/lib/asan/asan_fake_stack.cpp
@@ -107,7 +107,12 @@ FakeFrame *FakeStack::Allocate(uptr stack_size_log, uptr class_id,
     FakeFrame *res = reinterpret_cast<FakeFrame *>(
         GetFrame(stack_size_log, class_id, pos));
     res->real_stack = real_stack;
-    *SavedFlagPtr(reinterpret_cast<uptr>(res), class_id) = &flags[pos];
+    u8 **saved_flag_ptr = SavedFlagPtr(reinterpret_cast<uptr>(res), class_id);
+    *saved_flag_ptr = &flags[pos];
+
+    // Poison the last word of FakeFrame
+    u64 *shadow = reinterpret_cast<u64*>(MemToShadow(reinterpret_cast<uptr>(saved_flag_ptr)));
+    *shadow = kMagic8;
     return res;
   }
   return nullptr; // We are out of fake stack.

``````````

</details>


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


More information about the llvm-commits mailing list