hwasan: Compatibility fixes for short granules.
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 27 Sep 2019 01:02:10 +0000 (01:02 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 27 Sep 2019 01:02:10 +0000 (01:02 +0000)
commitc336557f0238dba72718e499bb345d0dd87305fc
treee4e28be592b4447219c84abe5cc03f2b5a99b5c8
parentd5d62a99a91391f7dd6f18cb1e8f2cb7ab06ded6
hwasan: Compatibility fixes for short granules.

We can't use short granules with stack instrumentation when targeting older
API levels because the rest of the system won't understand the short granule
tags stored in shadow memory.

Moreover, we need to be able to let old binaries (which won't understand
short granule tags) run on a new system that supports short granule
tags. Such binaries will call the __hwasan_tag_mismatch function when their
outlined checks fail. We can compensate for the binary's lack of support
for short granules by implementing the short granule part of the check in
the __hwasan_tag_mismatch function. Unfortunately we can't do anything about
inline checks, but I don't believe that we can generate these by default on
aarch64, nor did we do so when the ABI was fixed.

A new function, __hwasan_tag_mismatch_v2, is introduced that lets code
targeting the new runtime avoid redoing the short granule check. Because tag
mismatches are rare this isn't important from a performance perspective; the
main benefit is that it introduces a symbol dependency that prevents binaries
targeting the new runtime from running on older (i.e. incompatible) runtimes.

Differential Revision: https://reviews.llvm.org/D68059

llvm-svn: 373035
12 files changed:
compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
compiler-rt/test/hwasan/TestCases/stack-oob.c
compiler-rt/test/hwasan/lit.cfg.py
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll
llvm/test/Instrumentation/HWAddressSanitizer/alloca-compat.ll [new file with mode: 0644]
llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
llvm/test/Instrumentation/HWAddressSanitizer/basic-compat.ll [new file with mode: 0644]
llvm/test/Instrumentation/HWAddressSanitizer/basic.ll