diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp --- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp +++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp @@ -416,7 +416,8 @@ } static const void *AllocationBegin(const void *p) { - const void *untagged_ptr = UntagPtr(p); + const void *untagged_ptr = + __hwasan::InTaggableRegion(reinterpret_cast(p)) ? UntagPtr(p) : p; if (!untagged_ptr) return nullptr; @@ -432,12 +433,14 @@ return (const void *)AddTagToPointer((uptr)beg, tag); } -static uptr AllocationSize(const void *tagged_ptr) { - const void *untagged_ptr = UntagPtr(tagged_ptr); +static uptr AllocationSize(const void *p) { + const void *untagged_ptr = + __hwasan::InTaggableRegion(reinterpret_cast(p)) ? UntagPtr(p) : p; if (!untagged_ptr) return 0; const void *beg = allocator.GetBlockBegin(untagged_ptr); - Metadata *b = (Metadata *)allocator.GetMetaData(untagged_ptr); - if (beg != untagged_ptr) return 0; + if (!beg) + return 0; + Metadata *b = (Metadata *)allocator.GetMetaData(beg); return b->GetRequestedSize(); } diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/malloc_usable_size.c b/compiler-rt/test/sanitizer_common/TestCases/Linux/malloc_usable_size.c --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/malloc_usable_size.c +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/malloc_usable_size.c @@ -3,9 +3,6 @@ // Must not be implemented, no other reason to install interceptors. // XFAIL: ubsan -// FIXME: Implement. -// XFAIL: hwasan-aliasing - #include #include #include diff --git a/compiler-rt/test/sanitizer_common/TestCases/get_allocated_begin.cpp b/compiler-rt/test/sanitizer_common/TestCases/get_allocated_begin.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/get_allocated_begin.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/get_allocated_begin.cpp @@ -3,9 +3,6 @@ // Must not be implemented, no other reason to install interceptors. // XFAIL: ubsan -// FIXME: Implement. -// XFAIL: hwasan-aliasing - #include #include #include