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

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


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

>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 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=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:
+}

>From 056ed1ff3b020bdf9b3dac94177672d26dd22e44 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Wed, 28 Feb 2024 16:36:16 -0800
Subject: [PATCH 2/2] format

Created using spr 1.3.4
---
 compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c b/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c
index 69b10dec042cd0..2d7ed2ab5ee242 100644
--- a/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c
+++ b/compiler-rt/test/hwasan/TestCases/longjmp-out-of-range.c
@@ -1,12 +1,11 @@
 // 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>
+#include <stdlib.h>
 
-__attribute__((noinline))
-int f(void *caller_frame) {
+__attribute__((noinline)) int f(void *caller_frame) {
   int z = 0;
   int *volatile p = &z;
   // Tag of local is never zero.



More information about the llvm-commits mailing list