From 0f770f4d00e34249595a68df1be11df87b5149d7 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Wed, 9 Mar 2022 16:16:24 -0800 Subject: [PATCH] [NFC] [HWASan] document why we tag Size but untag AlignedSize. --- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 798d8ff..5c550b9 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 -- 2.7.4