[PATCH] D63908: hwasan: Improve precision of checks using short granule tags.

Peter Collingbourne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 27 17:17:33 PDT 2019


pcc created this revision.
pcc added a reviewer: eugenis.
Herald added subscribers: Sanitizers, cfe-commits, jfb, hiraditya, javed.absar, kubamracek.
Herald added projects: clang, Sanitizers, LLVM.

A short granule is a granule of size between 1 and `TG-1` bytes. The size
of a short granule is stored at the location in shadow memory where the
granule's tag is normally stored, while the granule's actual tag is stored
in the last byte of the granule. This means that in order to verify that a
pointer tag matches a memory tag, HWASAN must check for two possibilities:

- the pointer tag is equal to the memory tag in shadow memory, or
- the shadow memory tag is actually a short granule size, the value being loaded is in bounds of the granule and the pointer tag is equal to the last byte of the granule.

Pointer tags between 1 to `TG-1` are possible and are as likely as any other
tag. This means that these tags in memory have two interpretations: the full
tag interpretation (where the pointer tag is between 1 and `TG-1` and the
last byte of the granule is ordinary data) and the short tag interpretation
(where the pointer tag is stored in the granule).

When HWASAN detects an error near a memory tag between 1 and `TG-1`, it
will show both the memory tag and the last byte of the granule. Currently,
it is up to the user to disambiguate the two possibilities.

Because this functionality obsoletes the right aligned heap feature of
the HWASAN memory allocator (and because we can no longer easily test
it), the feature is removed.

Also update the documentation to cover both short granule tags and
outlined checks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63908

Files:
  clang/docs/HardwareAssistedAddressSanitizerDesign.rst
  compiler-rt/lib/hwasan/hwasan_allocator.cpp
  compiler-rt/lib/hwasan/hwasan_checks.h
  compiler-rt/lib/hwasan/hwasan_flags.inc
  compiler-rt/lib/hwasan/hwasan_report.cpp
  compiler-rt/lib/hwasan/hwasan_report.h
  compiler-rt/test/hwasan/TestCases/heap-buffer-overflow.c
  compiler-rt/test/hwasan/TestCases/random-align-right.c
  compiler-rt/test/hwasan/TestCases/stack-oob.c
  compiler-rt/test/hwasan/TestCases/tail-magic.c
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll
  llvm/test/Instrumentation/HWAddressSanitizer/alloca-with-calls.ll
  llvm/test/Instrumentation/HWAddressSanitizer/alloca.ll
  llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
  llvm/test/Instrumentation/HWAddressSanitizer/kernel-alloca.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63908.206968.patch
Type: text/x-patch
Size: 49014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190628/d3707c60/attachment-0001.bin>


More information about the cfe-commits mailing list