Skip to content

Commit 4c83674

Browse files
committed
[HWASAN] Fix HwasanReallocate in aliasing mode
HWASAN_ALIASING_MODE needs to untag only primary allocator pointers. Reviewed By: kstoimenov Differential Revision: https://reviews.llvm.org/D149293
1 parent 44363f2 commit 4c83674

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler-rt/lib/hwasan/hwasan_allocator.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,12 @@ static void *HwasanReallocate(StackTrace *stack, void *tagged_ptr_old,
384384
if (tagged_ptr_old && tagged_ptr_new) {
385385
Metadata *meta =
386386
reinterpret_cast<Metadata *>(allocator.GetMetaData(untagged_ptr_old));
387-
internal_memcpy(
388-
UntagPtr(tagged_ptr_new), untagged_ptr_old,
389-
Min(new_size, static_cast<uptr>(meta->GetRequestedSize())));
387+
void *untagged_ptr_new =
388+
InTaggableRegion(reinterpret_cast<uptr>(tagged_ptr_new))
389+
? UntagPtr(tagged_ptr_new)
390+
: tagged_ptr_new;
391+
internal_memcpy(untagged_ptr_new, untagged_ptr_old,
392+
Min(new_size, static_cast<uptr>(meta->GetRequestedSize())));
390393
HwasanDeallocate(stack, tagged_ptr_old);
391394
}
392395
return tagged_ptr_new;

compiler-rt/test/sanitizer_common/TestCases/max_allocation_size.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
// win32 is disabled due to failing errno tests.
4444
// UNSUPPORTED: ubsan, target={{.*windows-msvc.*}}
4545

46-
// FIXME: Something crashes.
47-
// XFAIL: hwasan-aliasing
48-
4946
#include <assert.h>
5047
#include <errno.h>
5148
#include <limits>

0 commit comments

Comments
 (0)