[llvm] 0f770f4 - [NFC] [HWASan] document why we tag Size but untag AlignedSize.

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 16:18:35 PST 2022


Author: Florian Mayer
Date: 2022-03-09T16:18:04-08:00
New Revision: 0f770f4d00e34249595a68df1be11df87b5149d7

URL: https://github.com/llvm/llvm-project/commit/0f770f4d00e34249595a68df1be11df87b5149d7
DIFF: https://github.com/llvm/llvm-project/commit/0f770f4d00e34249595a68df1be11df87b5149d7.diff

LOG: [NFC] [HWASan] document why we tag Size but untag AlignedSize.

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 798d8ff2920f9..5c550b99baf9b 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1350,6 +1350,10 @@ bool HWAddressSanitizer::instrumentStack(
     auto TagEnd = [&](Instruction *Node) {
       IRB.SetInsertPoint(Node);
       Value *UARTag = getUARTag(IRB, StackTag);
+      // When untagging, use the `AlignedSize` because we need to set the tags
+      // for the entire alloca to zero. If we used `Size` here, we would
+      // keep the last granule tagged, and store zero in the last byte of the
+      // last granule, due to how short granules are implemented.
       tagAlloca(IRB, AI, UARTag, AlignedSize);
     };
     // Calls to functions that may return twice (e.g. setjmp) confuse the


        


More information about the llvm-commits mailing list