[compiler-rt] [HWASAN]Implement memcmp interceptor in HWASAN (PR #67204)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 10:52:43 PDT 2023


================
@@ -0,0 +1,15 @@
+// RUN: %clangxx_hwasan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_hwasan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_hwasan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_hwasan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+// REQUIRES: pointer-tagging
+
+#include <string.h>
+int main(int argc, char **argv) {
+  char a1[] = {static_cast<char>(argc), 2, 3, 4};
+  char a2[] = {1, static_cast<char>(2*argc), 3, 4};
+  int res = memcmp(a1, a2, 4 + argc);  // BOOM
+  // CHECK: HWAddressSanitizer: tag-mismatch on address
----------------
vitalybuka wrote:

Can you try to remove // REQUIRES: pointer-tagging
and use malloc, instead of stack
and test on x86 host ?


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


More information about the llvm-commits mailing list