[compiler-rt] de916a7 - Revert "[hwasan] do not check if freed pointer belonged to allocator."

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 20 04:21:19 PDT 2021


Author: Florian Mayer
Date: 2021-08-20T12:21:00+01:00
New Revision: de916a7b12adc842a2cc23505d78412e8b5166d2

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

LOG: Revert "[hwasan] do not check if freed pointer belonged to allocator."

This reverts commit 119146f8ae25c31ea630a15761a6fba6b7eb909c.

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 3e7271f93fb61..63d86cf99e582 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp
@@ -208,7 +208,8 @@ static bool PointerAndMemoryTagsMatch(void *tagged_ptr) {
 static bool CheckInvalidFree(StackTrace *stack, void *untagged_ptr,
                              void *tagged_ptr) {
   // This function can return true if halt_on_error is false.
-  if (!PointerAndMemoryTagsMatch(tagged_ptr)) {
+  if (!allocator.PointerIsMine(untagged_ptr) ||
+      !PointerAndMemoryTagsMatch(tagged_ptr)) {
     ReportInvalidFree(stack, reinterpret_cast<uptr>(tagged_ptr));
     return true;
   }


        


More information about the llvm-commits mailing list