This is an archive of the discontinued LLVM Phabricator instance.

[HWASan] Port HWASan to Linux x86-64 (compiler-rt)
ClosedPublic

Authored by alekseyshl on Mar 20 2018, 2:41 PM.

Details

Summary

Porting HWASan to Linux x86-64, the second 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.

Diff Detail

Repository
rL LLVM

Event Timeline

alekseyshl created this revision.Mar 20 2018, 2:41 PM
Herald added subscribers: Restricted Project, delcypher, kristof.beyls and 3 others. · View Herald TranscriptMar 20 2018, 2:41 PM
alekseyshl edited the summary of this revision. (Show Details)Mar 21 2018, 10:28 AM
eugenis accepted this revision.Mar 21 2018, 4:44 PM
eugenis added inline comments.
lib/hwasan/hwasan.cc
257 ↗(On Diff #139200)

It's actually added because the kernel has other plans for low values of brk immediate.

268 ↗(On Diff #139200)

We could do the same thing with assembly constraint in aarch64 branch to put the pointer in x0. Let's not touch that code for now, but please add a FIXME.

lib/hwasan/hwasan_linux.cc
214 ↗(On Diff #139200)

This is mostly a copy of the comment above. Please factor out the common part.

This revision is now accepted and ready to land.Mar 21 2018, 4:44 PM
alekseyshl marked 3 inline comments as done.
  • Adjust comments

Comments addressed

eugenis accepted this revision.Mar 22 2018, 1:50 PM
This revision was automatically updated to reflect the committed changes.