Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test][hwasan] Implement sanitizer_specific for HWASAN #75280

Conversation

vitalybuka
Copy link
Collaborator

No description provided.

@llvmbot
Copy link

llvmbot commented Dec 13, 2023

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/75280.diff

1 Files Affected:

  • (modified) compiler-rt/test/sanitizer_common/sanitizer_specific.h (+13)
diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
index 898899f00e370..541af18a74979 100644
--- a/compiler-rt/test/sanitizer_common/sanitizer_specific.h
+++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h
@@ -31,6 +31,19 @@ static void make_mem_good(void *p, size_t s) {
 static void make_mem_bad(void *p, size_t s) {
   __asan_poison_memory_region(p, s);
 }
+#elif __has_feature(hwaddress_sanitizer)
+#  include <sanitizer/hwasan_interface.h>
+#  include <stdlib.h>
+static void check_mem_is_good(void *p, size_t s) {
+  if (__hwasan_test_shadow(p, s) != -1)
+    abort();
+}
+static void make_mem_good(void *p, size_t s) {
+  __hwasan_tag_memory(p, __hwasan_get_tag_from_pointer(p), s);
+}
+static void make_mem_bad(void *p, size_t s) {
+  __hwasan_tag_memory(p, ~__hwasan_get_tag_from_pointer(p), s);
+}
 #else
 static void check_mem_is_good(void *p, size_t s) {}
 static void make_mem_good(void *p, size_t s) {}

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
Created using spr 1.3.4
Copy link

github-actions bot commented Dec 13, 2023

:white_check_mark: With the latest revision this PR passed the C/C++ code formatter.

Created using spr 1.3.4
@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.testhwasan-implement-sanitizer_specific-for-hwasan to main December 13, 2023 22:25
@vitalybuka vitalybuka merged commit c636b18 into main Dec 13, 2023
4 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/testhwasan-implement-sanitizer_specific-for-hwasan branch December 13, 2023 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants