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

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 14:16:10 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:

this test is likely wrong on 'memcpy(p, a, sizeof(a));' not memcmp
it should free after memcpy

that why I asking to '// CHECK:' for other events
eg. stack trace lines


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


More information about the llvm-commits mailing list