[compiler-rt] 3511022 - [HWASan] Untag argument to __hwasan_tag_memory.

Matt Morehouse via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 17:09:03 PDT 2021


Author: Matt Morehouse
Date: 2021-04-21T17:08:43-07:00
New Revision: 3511022f5f0a8cce67b41a63c33f4f84159968e9

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

LOG: [HWASan] Untag argument to __hwasan_tag_memory.

__hwasan_tag_memory expects untagged pointers, so make sure our pointer
is untagged.

Added: 
    

Modified: 
    compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp
index 1abe209c10b5f..285a321c1f2eb 100644
--- a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp
+++ b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp
@@ -8,7 +8,10 @@
 #include <sanitizer/hwasan_interface.h>
 
 int main() {
-  char *p = (char *)malloc(4096);
+  void *alloc = malloc(4096);
+
+  // __hwasan_tag_memory expects untagged pointers.
+  char *p = (char *)__hwasan_tag_pointer(alloc, 0);
   assert(p);
 
   __hwasan_tag_memory(p, 1, 32);
@@ -26,5 +29,5 @@ int main() {
   // CHECK-NEXT:   {{.*}}0: 0
   // CHECK-NEXT:   {{.*}}0: 4
 
-  free(p);
+  free(alloc);
 }


        


More information about the llvm-commits mailing list