[hwasan] Don't report short-granule shadow as overwritten.
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 18 Aug 2021 16:36:48 +0000 (09:36 -0700)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Wed, 18 Aug 2021 18:25:57 +0000 (11:25 -0700)
commitfd51ab634143e0c1be49a62e16616ba5ab89273e
tree20e6fdecc93541c38eb59bcba128cf55bd6b0338
parent3dd8c9176be9515dc722b43d9ffb048b32ff5015
[hwasan] Don't report short-granule shadow as overwritten.

The shadow for a short granule is stored in the last byte of the
granule. Currently, if there's a tail-overwrite report (a
buffer-overflow-write in uninstrumented code), we report the shadow byte
as a mismatch against the magic.

Fix this bug by slapping the shadow into the expected value. This also
makes sure that if the uninstrumented WRITE does clobber the shadow
byte, it reports the shadow was actually clobbered as well.

Reviewed By: eugenis, fmayer

Differential Revision: https://reviews.llvm.org/D107938
compiler-rt/lib/hwasan/hwasan_allocator.cpp
compiler-rt/lib/hwasan/hwasan_report.cpp
compiler-rt/test/hwasan/TestCases/tail-magic.c