[HWASan] Port HWASan to Linux x86-64 (compiler-rt)
authorAlex Shlyapnikov <alekseys@google.com>
Fri, 23 Mar 2018 23:38:04 +0000 (23:38 +0000)
committerAlex Shlyapnikov <alekseys@google.com>
Fri, 23 Mar 2018 23:38:04 +0000 (23:38 +0000)
commit5cd35ed4fe72d96354c6f17ae071747ea62f0f14
treebad0c40ccfb9bba041e525bdcd2094d9081d31d6
parent5317f2e4c907fd1eca64772bdd2c23364adfaa77
[HWASan] Port HWASan to Linux x86-64 (compiler-rt)

Summary:
Porting HWASan to Linux x86-64, first of the three patches, compiler-rt part.

The approach is similar to ARM case, trap signal is used to communicate
memory tag check failure. int3 instruction is used to generate a signal,
access parameters are stored in nop [eax + offset] instruction immediately
following the int3 one

Had to add HWASan init on malloc because, due to much less interceptors
defined (most other sanitizers intercept much more and get initalized
via one of those interceptors or don't care about malloc), HWASan was not
initialized yet when libstdc++ was trying to allocate memory for its own
fixed-size heap, which led to CHECK-fail in AllocateFromLocalPool.

Also added the CHECK() failure handler with more detailed message and
stack reporting.

Reviewers: eugenis

Subscribers: kubamracek, dberris, mgorny, kristof.beyls, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 328385
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/hwasan/hwasan.cc
compiler-rt/lib/hwasan/hwasan.h
compiler-rt/lib/hwasan/hwasan_allocator.cc
compiler-rt/lib/hwasan/hwasan_interceptors.cc
compiler-rt/lib/hwasan/hwasan_linux.cc