[PATCH] D63119: hwasan: Add a tag_offset DWARF attribute to instrumented stack variables.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 20:42:58 PDT 2019


pcc created this revision.
pcc added reviewers: eugenis, echristo.
Herald added subscribers: hiraditya, javed.absar, aprantl, srhines.
Herald added a project: LLVM.

The goal is to improve hwasan's error reporting for stack use-after-return by
recording enough information to allow the specific variable that was accessed
to be identified based on the pointer's tag. Currently we record the PC and
lower bits of SP for each stack frame we create (which will eventually be
enough to derive the base tag used by the stack frame) but that's not enough
to determine the specific tag for each variable, which is the stack frame's
base tag XOR a value (the "tag offset") that is unique for each variable in
a function.

In IR, the tag offset is most naturally represented as part of a location
expression on the llvm.dbg.declare instruction. However, the presence of the
tag offset in the variable's actual location expression is likely to confuse
debuggers which won't know about tag offsets, and moreover the tag offset
is not required for a debugger to determine the location of the variable on
the stack, so at the DWARF level it is represented as an attribute so that
it will be ignored by debuggers that don't know about it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63119

Files:
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/BinaryFormat/Dwarf.h
  llvm/lib/BinaryFormat/Dwarf.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/CodeGen/AArch64/dbg-declare-tag-offset.ll
  llvm/test/Instrumentation/HWAddressSanitizer/dbg-declare-tag-offset.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63119.203970.patch
Type: text/x-patch
Size: 11793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190611/8e082c6c/attachment.bin>


More information about the llvm-commits mailing list