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

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 31 01:22:20 PDT 2025


https://github.com/brandb97 created https://github.com/llvm/llvm-project/pull/133689

None

>From 03cd392eb1bb027cf70421e4e9f0eb6e5180637b Mon Sep 17 00:00:00 2001
From: lidongyan <502024330056 at smail.nju.edu.cn>
Date: Mon, 31 Mar 2025 15:14:45 +0800
Subject: [PATCH] Poison last word of FakeFrame

---
 compiler-rt/lib/asan/asan_fake_stack.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/asan/asan_fake_stack.cpp b/compiler-rt/lib/asan/asan_fake_stack.cpp
index 7443ff166984d..f68dd31ab1610 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
+    u8 *shadow = reinterpret_cast<u8*>(MemToShadow(reinterpret_cast<uptr>(saved_flag_ptr)));
+    *shadow = kMagic1;
     return res;
   }
   return nullptr; // We are out of fake stack.



More information about the llvm-commits mailing list