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

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 11:40:35 PDT 2023


================
@@ -156,6 +156,35 @@ tag_t Thread::GenerateRandomTag(uptr num_bits) {
   return tag;
 }
 
+// Generate a (pseudo-)random non-zero tag and prevent collisions to neighboring
+// objects.
+tag_t Thread::GenerateRandomNonCollidingTag(uptr prev_ptr, uptr foll_ptr,
+                                            uptr num_bits) {
+  DCHECK_GT(num_bits, 0);
+  if (tagging_disabled_)
+    return 0;
+  tag_t tag;
+  tag_t previous_tag = *(tag_t *)MemToShadow(prev_ptr);
----------------
vitalybuka wrote:

There are other cases when HWASAN is non-deterministic, and they hard or impossible to solve. E.g. stack instrumentation. So instead I would rather recommend to adjust  expectations.

In general I don't have other than performance concerns, which not yet confirmed/measured. So I am OK to land this, but and undo later, if it provides measurable perf benefits.

Still I don't like that users may start to rely on this behavior.

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


More information about the llvm-commits mailing list