Skip to content

Commit 0f770f4

Browse files
committed
[NFC] [HWASan] document why we tag Size but untag AlignedSize.
1 parent 0123d2a commit 0f770f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,10 @@ bool HWAddressSanitizer::instrumentStack(
13501350
auto TagEnd = [&](Instruction *Node) {
13511351
IRB.SetInsertPoint(Node);
13521352
Value *UARTag = getUARTag(IRB, StackTag);
1353+
// When untagging, use the `AlignedSize` because we need to set the tags
1354+
// for the entire alloca to zero. If we used `Size` here, we would
1355+
// keep the last granule tagged, and store zero in the last byte of the
1356+
// last granule, due to how short granules are implemented.
13531357
tagAlloca(IRB, AI, UARTag, AlignedSize);
13541358
};
13551359
// Calls to functions that may return twice (e.g. setjmp) confuse the

0 commit comments

Comments
 (0)