CHECK(tagged_ptr);
RunFreeHooks(tagged_ptr);
- bool in_taggable_region =
- InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr));
- void *untagged_ptr = in_taggable_region ? UntagPtr(tagged_ptr) : tagged_ptr;
+ void *untagged_ptr = UntagPtr(tagged_ptr);
if (CheckInvalidFree(stack, untagged_ptr, tagged_ptr))
return;
u32 alloc_context_id = meta->GetAllocStackId();
u32 alloc_thread_id = meta->GetAllocThreadId();
+ bool in_taggable_region =
+ InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr));
+
// Check tail magic.
uptr tagged_size = TaggedSize(orig_size);
if (flags()->free_checks_tail_magic && orig_size &&
static void *HwasanReallocate(StackTrace *stack, void *tagged_ptr_old,
uptr new_size, uptr alignment) {
- void *untagged_ptr_old =
- InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr_old))
- ? UntagPtr(tagged_ptr_old)
- : tagged_ptr_old;
+ void *untagged_ptr_old = UntagPtr(tagged_ptr_old);
if (CheckInvalidFree(stack, untagged_ptr_old, tagged_ptr_old))
return nullptr;
void *tagged_ptr_new =
if (tagged_ptr_old && tagged_ptr_new) {
Metadata *meta =
reinterpret_cast<Metadata *>(allocator.GetMetaData(untagged_ptr_old));
- void *untagged_ptr_new =
- InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr_new))
- ? UntagPtr(tagged_ptr_new)
- : tagged_ptr_new;
+ void *untagged_ptr_new = UntagPtr(tagged_ptr_new);
internal_memcpy(untagged_ptr_new, untagged_ptr_old,
Min(new_size, static_cast<uptr>(meta->GetRequestedSize())));
HwasanDeallocate(stack, tagged_ptr_old);
}
static const void *AllocationBegin(const void *p) {
- const void *untagged_ptr =
- InTaggableRegion(reinterpret_cast<uptr>(p)) ? UntagPtr(p) : p;
+ const void *untagged_ptr = UntagPtr(p);
if (!untagged_ptr)
return nullptr;
}
static uptr AllocationSize(const void *p) {
- const void *untagged_ptr =
- InTaggableRegion(reinterpret_cast<uptr>(p)) ? UntagPtr(p) : p;
+ const void *untagged_ptr = UntagPtr(p);
if (!untagged_ptr) return 0;
const void *beg = allocator.GetBlockBegin(untagged_ptr);
if (!beg)
}
uptr PointsIntoChunk(void *p) {
- p = InTaggableRegion(reinterpret_cast<uptr>(p)) ? UntagPtr(p) : p;
+ p = UntagPtr(p);
uptr addr = reinterpret_cast<uptr>(p);
uptr chunk =
reinterpret_cast<uptr>(__hwasan::allocator.GetBlockBeginFastLocked(p));
}
uptr GetUserBegin(uptr chunk) {
- if (InTaggableRegion(chunk))
- CHECK_EQ(UntagAddr(chunk), chunk);
+ CHECK_EQ(UntagAddr(chunk), chunk);
void *block = __hwasan::allocator.GetBlockBeginFastLocked(
reinterpret_cast<void *>(chunk));
if (!block)
}
uptr GetUserAddr(uptr chunk) {
- tag_t mem_tag = *(tag_t *)__hwasan::MemToShadow(chunk);
if (!InTaggableRegion(chunk))
return chunk;
+ tag_t mem_tag = *(tag_t *)__hwasan::MemToShadow(chunk);
return AddTagToPointer(chunk, mem_tag);
}
LsanMetadata::LsanMetadata(uptr chunk) {
- if (InTaggableRegion(chunk))
- CHECK_EQ(UntagAddr(chunk), chunk);
+ CHECK_EQ(UntagAddr(chunk), chunk);
metadata_ =
chunk ? __hwasan::allocator.GetMetaData(reinterpret_cast<void *>(chunk))
: nullptr;
}
IgnoreObjectResult IgnoreObject(const void *p) {
- p = InTaggableRegion(reinterpret_cast<uptr>(p)) ? UntagPtr(p) : p;
+ p = UntagPtr(p);
uptr addr = reinterpret_cast<uptr>(p);
uptr chunk = reinterpret_cast<uptr>(__hwasan::allocator.GetBlockBegin(p));
if (!chunk)