[compiler-rt] 9fa938d - Revert "Properly restore SP tag on exceptions"

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 10:26:56 PDT 2023


Author: Florian Mayer
Date: 2023-06-05T10:26:33-07:00
New Revision: 9fa938d6873057ec4b180a5f53e4922d2f71e436

URL: https://github.com/llvm/llvm-project/commit/9fa938d6873057ec4b180a5f53e4922d2f71e436
DIFF: https://github.com/llvm/llvm-project/commit/9fa938d6873057ec4b180a5f53e4922d2f71e436.diff

LOG: Revert "Properly restore SP tag on exceptions"

This reverts commit 6a2e0cb418175bb985aa898604560110a77c43da.

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan_exceptions.cpp
    compiler-rt/lib/hwasan/hwasan_thread.cpp
    compiler-rt/test/hwasan/TestCases/try-catch.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan_exceptions.cpp b/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
index bf700bf568389..c9968a5e36037 100644
--- a/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
@@ -62,8 +62,7 @@ __hwasan_personality_wrapper(int version, _Unwind_Action actions,
 #error Unsupported architecture
 #endif
     uptr sp = get_cfa(context);
-    TagMemory(UntagAddr(sp), UntagAddr(fp) - UntagAddr(sp),
-              GetTagFromPointer(sp));
+    TagMemory(sp, fp - sp, 0);
   }
 
   return rc;

diff  --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cpp
index 2346c46e5bff3..c4ab091d956c5 100644
--- a/compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -93,9 +93,7 @@ void Thread::InitStackRingBuffer(uptr stack_buffer_start,
 
 void Thread::ClearShadowForThreadStackAndTLS() {
   if (stack_top_ != stack_bottom_)
-    TagMemory(UntagAddr(stack_bottom_),
-              UntagAddr(stack_top_) - UntagAddr(stack_bottom_),
-              GetTagFromPointer(stack_top_));
+    TagMemory(stack_bottom_, stack_top_ - stack_bottom_, 0);
   if (tls_begin_ != tls_end_)
     TagMemory(tls_begin_, tls_end_ - tls_begin_, 0);
 }

diff  --git a/compiler-rt/test/hwasan/TestCases/try-catch.cpp b/compiler-rt/test/hwasan/TestCases/try-catch.cpp
index 6b12dda0badfc..1449d8d6f81d0 100644
--- a/compiler-rt/test/hwasan/TestCases/try-catch.cpp
+++ b/compiler-rt/test/hwasan/TestCases/try-catch.cpp
@@ -1,6 +1,5 @@
 // This test is broken with shared libstdc++ / libc++ on Android.
 // RUN: %clangxx_hwasan -static-libstdc++ %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
-// RUN: %clangxx_hwasan -static-libstdc++ -DMALLOCEDSTACK %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
 // RUN: %clangxx_hwasan -static-libstdc++ -DNO_SANITIZE_F %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
 // RUN: %clangxx_hwasan_oldrt -static-libstdc++ %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=GOOD
 // RUN: %clangxx_hwasan_oldrt -static-libstdc++ %s -mllvm -hwasan-instrument-landing-pads=0 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=BAD
@@ -9,13 +8,8 @@
 // RISC-V target doesn't support oldrt
 // REQUIRES: aarch64-target-arch
 
-#include <cassert>
-#include <cstdio>
-#include <errno.h>
-#include <pthread.h>
-#include <sanitizer/hwasan_interface.h>
 #include <stdexcept>
-#include <string.h>
+#include <cstdio>
 
 static void optimization_barrier(void* arg) {
   asm volatile("" : : "r"(arg) : "memory");
@@ -48,12 +42,12 @@ __attribute__((noinline, no_sanitize("hwaddress"))) void after_catch() {
   hwasan_read(&x[0], sizeof(x));
 }
 
+
 __attribute__((noinline))
 #ifdef NO_SANITIZE_F
 __attribute__((no_sanitize("hwaddress")))
 #endif
-void *
-f(void *) {
+void f() {
   char x[1000];
   try {
     // Put two tagged frames on the stack, throw an exception from the deepest one.
@@ -69,32 +63,8 @@ f(void *) {
     // GOOD: hello
     printf("%s\n", e.what());
   }
-  return nullptr;
 }
 
 int main() {
-  __hwasan_enable_allocator_tagging();
-#ifdef MALLOCEDSTACK
-  pthread_attr_t attr;
-  void *stack = malloc(PTHREAD_STACK_MIN);
-  assert(pthread_attr_init(&attr) == 0);
-  if (pthread_attr_setstack(&attr, stack, PTHREAD_STACK_MIN) != 0) {
-    fprintf(stderr, "pthread_attr_setstack: %s", strerror(errno));
-    abort();
-  }
-  pthread_t thid;
-  if (pthread_create(&thid, &attr, f, nullptr) != 0) {
-    fprintf(stderr, "pthread_create: %s", strerror(errno));
-    abort();
-  }
-  void *ret;
-  if (pthread_join(thid, &ret) != 0) {
-    fprintf(stderr, "pthread_join: %s", strerror(errno));
-    abort();
-  }
-  assert(pthread_attr_destroy(&attr) == 0);
-  free(stack);
-#else
-  f(nullptr);
-#endif
+  f();
 }


        


More information about the llvm-commits mailing list