[hwasan] support hwasan-match-all-tag flag for callback memory access instrumentation
authorEnna1 <xumingjie.enna1@bytedance.com>
Sat, 27 May 2023 02:27:28 +0000 (10:27 +0800)
committerEnna1 <xumingjie.enna1@bytedance.com>
Sat, 27 May 2023 02:27:50 +0000 (10:27 +0800)
commitb33dcc5b1eda6a564138b0e86f726abf269fb561
tree6bf248372de9c80d15e9c9b4d53cf97728895f28
parentaf7aea365a2ae8dc51938a614353e1586072ef83
[hwasan] support hwasan-match-all-tag flag for callback memory access instrumentation

Currently, hwasan-match-all-tag flag is supported in inline memory access instrumentation and outline memory access instrumentation, but not supported in callback memory access instrumentation.

- For inline memory access instrumentation: a hwasan-match-all-tag check is added following the tag-mismtach check, if tag from pointer is mismatched with tag from shadow memory and tag from pointer is not equal with hwasan-match-all-tag, then a tag-mismatch will be report.
- For outline memory acess instrumentation: MatchAllTag is encoded in AccessInfo, when emit HWASAN memaccess symbols, asm-printer emits assembly instructions to check if tag from pointer is equal with hwasan-match-all-tag.
- For callback memory access instrumentation: hwasan-match-all-tag check is not implemented in `__hwasan_load`/`__hwasan_store`.

This patch implements a set of callback functions: `__hwasan_[load|store][1|2|4|8|16|n]_match_all` and `__hwasan_load[load|store][1|2|4|8|16|n]_match_all_noabort`, making hwasan-match-all-tag flag working for callback memory access instrumentation.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D149580
compiler-rt/lib/hwasan/hwasan.cpp
compiler-rt/lib/hwasan/hwasan_interface_internal.h
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll