[llvm-branch-commits] [clang-tools-extra] [lld] [libcxx] [compiler-rt] [llvm] [test][hwasan] Implement sanitizer_specific for HWASAN (PR #75280)

Thurston Dang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 13 09:19:12 PST 2023


================
@@ -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);
----------------
thurstond wrote:

Is this guaranteed to make memory bad if it's a short granule?

Also, in the rare case where the tag was 255, bitwise NOT results in the confusing tag value of zero.

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


More information about the llvm-branch-commits mailing list