[compiler-rt] [HWASan] Prevent same tag for adjacent heap objects (PR #69337)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 07:54:02 PDT 2023


================
@@ -237,7 +237,10 @@ static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment,
   if (InTaggableRegion(reinterpret_cast<uptr>(user_ptr)) &&
       atomic_load_relaxed(&hwasan_allocator_tagging_enabled) &&
       flags()->tag_in_malloc && malloc_bisect(stack, orig_size)) {
-    tag_t tag = t ? t->GenerateRandomTag() : kFallbackAllocTag;
+    tag_t tag = t ? t->GenerateRandomNonCollidingTag((uptr)user_ptr - 1,
----------------
KonradHohentanner wrote:

Done, I also lifted the !tag check from GenerateRandomTag as you suggested and added the check to the other locations where the function was called and a non-zero tag is needed.

https://github.com/llvm/llvm-project/pull/69337


More information about the llvm-commits mailing list