[PATCH] D58857: [HWASan] Save + print registers when tag mismatch occurs in AArch64.

Mitch Phillips via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 16:51:11 PST 2019


hctim created this revision.
hctim added reviewers: pcc, eugenis.
Herald added subscribers: jdoerfert, hiraditya, kristof.beyls, krytarowski, javed.absar, mgorny, kubamracek.
Herald added projects: Sanitizers, LLVM.

This change change the instrumentation to allow users to view the registers at the point at which tag mismatch occured. Most of the heavy lifting is done in
the runtime library, where we save the registers to the stack and emit unwind information. This allows us to reduce the overhead, as very little additional w
ork needs to be done in each __hwasan_check instance.

In this implementation, the fast path of __hwasan_check is unmodified. There are an additional 4 instructions (16B) emitted in the slow path in every __hwasa
n_check instance. This may increase binary size somewhat, but as most of the work is done in the runtime library, it's manageable.

The failure trace now contains a list of registers at the point of which the failure occured, in a format similar to that of Android's tombstones. It current
ly has the following format:

Registers where the failure occurred (pc 0x0055555561b4):

  x0  0000000000000014  x1  0000007ffffff6c0  x2  1100007ffffff6d0  x3  12000056ffffe025
  x4  0000007fff800000  x5  0000000000000014  x6  0000007fff800000  x7  0000000000000001
  x8  12000056ffffe020  x9  0200007700000000  x10 0200007700000000  x11 0000000000000000
  x12 0000007fffffdde0  x13 0000000000000000  x14 02b65b01f7a97490  x15 0000000000000000
  x16 0000007fb77376b8  x17 0000000000000012  x18 0000007fb7ed6000  x19 0000005555556078
  x20 0000007ffffff768  x21 0000007ffffff778  x22 0000000000000001  x23 0000000000000000
  x24 0000000000000000  x25 0000000000000000  x26 0000000000000000  x27 0000000000000000
  x28 0000000000000000  x29 0000007ffffff6f0  x30 00000055555561b4

... and prints after the dump of memory tags around the buggy address.

Every register is saved exactly as it was at the point where the tag mismatch occurs, with the exception of x16/x17. These registers are used in the tag mism
atch calculation as scratch registers during __hwasan_check, and cannot be saved without affecting the fast path. As these registers are designated as scratc
h registers for linking, there should be no important information in them that could aid in debugging.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58857

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_interface_internal.h
  compiler-rt/lib/hwasan/hwasan_linux.cc
  compiler-rt/lib/hwasan/hwasan_report.cc
  compiler-rt/lib/hwasan/hwasan_report.h
  compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll
  llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58857.189011.patch
Type: text/x-patch
Size: 14787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190302/0467edd0/attachment-0001.bin>


More information about the llvm-commits mailing list