[compiler-rt] 493565a - [HWASan] Run LAM tests with -hwasan-generate-tags-with-calls.
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 08:11:20 PDT 2021
Author: Matt Morehouse
Date: 2021-06-18T08:10:51-07:00
New Revision: 493565a4aa7cc3b48e2b5c51b541a438fc449217
URL: https://github.com/llvm/llvm-project/commit/493565a4aa7cc3b48e2b5c51b541a438fc449217
DIFF: https://github.com/llvm/llvm-project/commit/493565a4aa7cc3b48e2b5c51b541a438fc449217.diff
LOG: [HWASan] Run LAM tests with -hwasan-generate-tags-with-calls.
The default callback instrumentation in x86 LAM mode uses ASLR bits
to randomly choose a tag, and thus has a 1/64 chance of choosing a
stack tag of 0, causing stack tests to fail intermittently. By using
__hwasan_generate_tag to pick tags, we guarantee non-zero tags and
eliminate the test flakiness.
aarch64 doesn't seem to have this problem using thread-local addresses
to pick tags, so perhaps we can remove this workaround once we implement
a similar mechanism for LAM.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D104470
Added:
Modified:
compiler-rt/lib/hwasan/hwasan.cpp
compiler-rt/test/hwasan/lit.cfg.py
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index 056ca18dfde00..6b4aefcffce55 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -546,7 +546,7 @@ void __hwasan_print_memory_usage() {
Printf("%s\n", s.data());
}
-static const u8 kFallbackTag = 0xBB;
+static const u8 kFallbackTag = 0xBB & kTagMask;
u8 __hwasan_generate_tag() {
Thread *t = GetCurrentThread();
diff --git a/compiler-rt/test/hwasan/lit.cfg.py b/compiler-rt/test/hwasan/lit.cfg.py
index 62967fff5b1ec..c94d5e0dac83d 100644
--- a/compiler-rt/test/hwasan/lit.cfg.py
+++ b/compiler-rt/test/hwasan/lit.cfg.py
@@ -22,6 +22,12 @@
# the x86_64 implementation is for testing purposes only there is no
# equivalent target feature implemented on x86_64.
clang_hwasan_common_cflags += ["-mcmodel=large"]
+
+ # The callback instrumentation used on x86_64 has a 1/64 chance of choosing a
+ # stack tag of 0. This causes stack tests to become flaky, so we force tags
+ # to be generated via calls to __hwasan_generate_tag, which never returns 0.
+ # TODO: See if we can remove this once we use the outlined instrumentation.
+ clang_hwasan_common_cflags += ["-mllvm", "-hwasan-generate-tags-with-calls=1"]
clang_hwasan_cflags = clang_hwasan_common_cflags + ["-mllvm", "-hwasan-globals",
"-mllvm", "-hwasan-use-short-granules",
"-mllvm", "-hwasan-instrument-landing-pads=0",
More information about the llvm-commits
mailing list