[PATCH] D56672: [HWASAN] Instrument globals

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 14 10:23:01 PST 2019


evgeny777 created this revision.
evgeny777 added reviewers: kcc, eugenis.

This patch enables access checks for global variables in HWASAN. 
The algorithm is fairly simple:

For each global variable (GV) we can instrument

- Replace it with one aligned to `1 << kDefaultShadowScale`
- Generate tag based on global name:  `hash_value(GV->getName())`
- Replace all uses of pointer to this variable with tagged pointer, i.e:

  i64 *@foo -> i64* bitcast (i8* getelementptr (i8, i8* bitcast (i64* @foo to i8*), i64 N) to i64*)
  where N is a tag shifted by 56 bits

Patch adds calls to `__hwasan_register_globals` and `__hwasan_unregister_globals` to tag and untag globals memory.

Everything else is handled HWASAN function pass after that.


https://reviews.llvm.org/D56672

Files:
  include/llvm/InitializePasses.h
  include/llvm/Transforms/Instrumentation.h
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  lib/Transforms/Instrumentation/Instrumentation.cpp
  test/Instrumentation/HWAddressSanitizer/globals.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56672.181580.patch
Type: text/x-patch
Size: 19121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190114/aaf4b179/attachment.bin>


More information about the llvm-commits mailing list