summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/arch/arm64/context_arm64.cc8
-rw-r--r--runtime/thread.cc10
2 files changed, 17 insertions, 1 deletions
diff --git a/runtime/arch/arm64/context_arm64.cc b/runtime/arch/arm64/context_arm64.cc
index 0f0814a675..16f4792e98 100644
--- a/runtime/arch/arm64/context_arm64.cc
+++ b/runtime/arch/arm64/context_arm64.cc
@@ -23,6 +23,12 @@
#include "quick/quick_method_frame_info.h"
#include "thread-current-inl.h"
+#if __has_feature(hwaddress_sanitizer)
+#include <sanitizer/hwasan_interface.h>
+#else
+#define __hwasan_handle_longjmp(sp)
+#endif
+
namespace art {
namespace arm64 {
@@ -139,6 +145,8 @@ void Arm64Context::DoLongJump() {
}
// Ensure the Thread Register contains the address of the current thread.
DCHECK_EQ(reinterpret_cast<uintptr_t>(Thread::Current()), gprs[TR]);
+ // Tell HWASan about the new stack top.
+ __hwasan_handle_longjmp(reinterpret_cast<void*>(gprs[SP]));
// The Marking Register will be updated by art_quick_do_long_jump.
art_quick_do_long_jump(gprs, fprs);
}
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 8a637a250d..19fe4ea7c5 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -25,6 +25,12 @@
#include <sys/resource.h>
#include <sys/time.h>
+#if __has_feature(hwaddress_sanitizer)
+#include <sanitizer/hwasan_interface.h>
+#else
+#define __hwasan_tag_pointer(p, t) (p)
+#endif
+
#include <algorithm>
#include <bitset>
#include <cerrno>
@@ -623,7 +629,9 @@ void Thread::InstallImplicitProtection() {
#endif
volatile char space[kPageSize - (kAsanMultiplier * 256)];
char sink ATTRIBUTE_UNUSED = space[zero]; // NOLINT
- if (reinterpret_cast<uintptr_t>(space) >= target + kPageSize) {
+ // Remove tag from the pointer. Nop in non-hwasan builds.
+ uintptr_t addr = reinterpret_cast<uintptr_t>(__hwasan_tag_pointer(space, 0));
+ if (addr >= target + kPageSize) {
Touch(target);
}
zero *= 2; // Try to avoid tail recursion.