[compiler-rt] b55f05a - [NFC][hwasan] Don't tag secondary allocations on free

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 13:36:22 PDT 2023


Author: Vitaly Buka
Date: 2023-07-26T13:36:10-07:00
New Revision: b55f05a3f25338684432346082e873813d400b36

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

LOG: [NFC][hwasan] Don't tag secondary allocations on free

OnUnmap will tag it to zero anyway.

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D156282

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 48f1873ed68217..c99d730e059faa 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp
@@ -345,7 +345,8 @@ static void HwasanDeallocate(StackTrace *stack, void *tagged_ptr) {
     internal_memset(aligned_ptr, flags()->free_fill_byte, fill_size);
   }
   if (in_taggable_region && flags()->tag_in_free && malloc_bisect(stack, 0) &&
-      atomic_load_relaxed(&hwasan_allocator_tagging_enabled)) {
+      atomic_load_relaxed(&hwasan_allocator_tagging_enabled) &&
+      allocator.FromPrimary(untagged_ptr) /* Secondary 0-tag and unmap.*/) {
     // Always store full 8-bit tags on free to maximize UAF detection.
     tag_t tag;
     if (t) {


        


More information about the llvm-commits mailing list