[PATCH] D63908: hwasan: Improve precision of checks using short granule tags.

Evgenii Stepanov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 3 17:24:42 PDT 2019


eugenis added inline comments.


================
Comment at: compiler-rt/lib/hwasan/hwasan_allocator.cpp:159
                     ? (t ? t->GenerateRandomTag() : kFallbackAllocTag)
                     : 0;
+    uptr tag_size = orig_size ? orig_size : 1;
----------------
When !(flags()->tag_in_malloc && malloc_bisect(stack, orig_size)), the tail tag should be 0 as well.


================
Comment at: compiler-rt/lib/hwasan/hwasan_checks.h:69
+    return true;
+  if (mem_tag > 15)
+    return false;
----------------
s/15/kShadowAlignment -1/


================
Comment at: compiler-rt/lib/hwasan/hwasan_checks.h:113
+  if (UNLIKELY(tail_sz != 0 && !PossiblyShortTagMatches(
+                                   *shadow_last, end & ~0xfull, tail_sz))) {
+    SigTrap<0x20 * (EA == ErrorAction::Recover) +
----------------
0xfull, nice :)
A named constant please.


================
Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:1195
+      auto *NewAI = new AllocaInst(
+          TypeWithPadding, AI->getType()->getAddressSpace(), nullptr, "", AI);
+      NewAI->takeName(AI);
----------------
Good. I think we will need to do the same in MTE patches, but for different reason.

There is something in BasicAA that thinks that a store of size 16 (in MachineInstr) can not possibly alias with a smaller alloca, so simply increasing alloca alignment is not enough.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63908/new/

https://reviews.llvm.org/D63908





More information about the cfe-commits mailing list