[compiler-rt] 0e08a85 - [HWASA] Restore LsanMetadata from D141642 Diff5

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 23:46:04 PST 2023


Author: Vitaly Buka
Date: 2023-01-17T23:45:51-08:00
New Revision: 0e08a85429567343f087fa8631c2a6a05258bf70

URL: https://github.com/llvm/llvm-project/commit/0e08a85429567343f087fa8631c2a6a05258bf70
DIFF: https://github.com/llvm/llvm-project/commit/0e08a85429567343f087fa8631c2a6a05258bf70.diff

LOG: [HWASA] Restore LsanMetadata from D141642 Diff5

Unlike asan, we can't use pointer arithmetics to get from user ptr to
metadata. Asan does not use CombinedAllocator::GetMetadata and store
metadata next to the user data.

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan_allocator.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp
index 9f7d1f3841d96..03081ab1fdcc5 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp
@@ -534,7 +534,8 @@ uptr GetUserBegin(uptr chunk) {
 
 LsanMetadata::LsanMetadata(uptr chunk) {
   metadata_ =
-      chunk ? (reinterpret_cast<__hwasan::Metadata *>(chunk) - 1) : nullptr;
+      chunk ? __hwasan::allocator.GetMetaData(reinterpret_cast<void *>(chunk))
+            : nullptr;
 }
 
 bool LsanMetadata::allocated() const {


        


More information about the llvm-commits mailing list