[compiler-rt] Poison last word of FakeFrame (PR #133687)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 31 00:46:20 PDT 2025
https://github.com/brandb97 created https://github.com/llvm/llvm-project/pull/133687
Fixes [issue#122640](https://github.com/llvm/llvm-project/issues/133640)
>From 54d9107cf08a533cf625118989c0cad9b9ee6210 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..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.
More information about the llvm-commits
mailing list