[compiler-rt] [HWASan] add check for hwasan_handle_longjmp ignore logic (PR #83359)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 16:24:58 PST 2024


https://github.com/fmayer created https://github.com/llvm/llvm-project/pull/83359

None

>From c25f9b3bd50047416903df92a867796780c8ce7e Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Wed, 28 Feb 2024 16:24:47 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../hwasan/TestCases/longjmp-out-of-range.c   | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c

diff --git a/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c b/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c
new file mode 100644
index 00000000000000..69b10dec042cd0
--- /dev/null
+++ b/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c
@@ -0,0 +1,21 @@
+// RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1 | FileCheck %s
+
+// REQUIRES: pointer-tagging
+#include <stdlib.h>
+#include <assert.h>
+#include <sanitizer/hwasan_interface.h>
+
+__attribute__((noinline))
+int f(void *caller_frame) {
+  int z = 0;
+  int *volatile p = &z;
+  // Tag of local is never zero.
+  assert(__hwasan_tag_pointer(p, 0) != p);
+  __hwasan_handle_longjmp(NULL);
+  return p[0];
+}
+
+int main() {
+  return f(__builtin_frame_address(0));
+  // CHECK: HWASan is ignoring requested __hwasan_handle_longjmp:
+}



More information about the llvm-commits mailing list