[hwasan] Don't require untagged pointer in __hwasan_tag_memory
authorVitaly Buka <vitalybuka@google.com>
Wed, 5 Apr 2023 23:46:42 +0000 (16:46 -0700)
committerVitaly Buka <vitalybuka@google.com>
Tue, 11 Apr 2023 18:18:58 +0000 (11:18 -0700)
Use likely have tagged pointer. I see no value making user to untag it.

Reviewed By: fmayer

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

compiler-rt/lib/hwasan/hwasan.cpp
compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp

index 0a5999c..097136f 100644 (file)
@@ -553,7 +553,7 @@ void __hwasan_store16_noabort(uptr p) {
 }
 
 void __hwasan_tag_memory(uptr p, u8 tag, uptr sz) {
-  TagMemoryAligned(p, sz, tag);
+  TagMemoryAligned(UntagAddr(p), sz, tag);
 }
 
 uptr __hwasan_tag_pointer(uptr p, u8 tag) {
index 2be0a05..ecf1d9b 100644 (file)
@@ -18,9 +18,7 @@ int main() {
   alloc[79] = 0xee;
   alloc[95] = 0xff;
 
-  // __hwasan_tag_memory expects untagged pointers.
-  char *p = (char *)__hwasan_tag_pointer(alloc, 0);
-  assert(p);
+  char *p = alloc;
 
   // Write tags to shadow.
   __hwasan_tag_memory(p, 1, 32);