[compiler-rt] 5511bfd - [hwasan] More realistic setjmp test.
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 9 12:27:47 PDT 2021
Author: Florian Mayer
Date: 2021-07-09T20:27:32+01:00
New Revision: 5511bfdb671505c1e7968ab8ef6032414bba3852
URL: https://github.com/llvm/llvm-project/commit/5511bfdb671505c1e7968ab8ef6032414bba3852
DIFF: https://github.com/llvm/llvm-project/commit/5511bfdb671505c1e7968ab8ef6032414bba3852.diff
LOG: [hwasan] More realistic setjmp test.
The existing one actually failed on the int* p, not on int z (as can be
seen by the fault being 8 bytes rather than 4).
This is also needed to make sure the stack safety analysis does not
classify the alloca as safe.
Reviewed By: hctim
Differential Revision: https://reviews.llvm.org/D105705
Added:
Modified:
compiler-rt/test/hwasan/TestCases/longjmp.c
Removed:
################################################################################
diff --git a/compiler-rt/test/hwasan/TestCases/longjmp.c b/compiler-rt/test/hwasan/TestCases/longjmp.c
index 700a1cbee329..86fff7a0a23a 100644
--- a/compiler-rt/test/hwasan/TestCases/longjmp.c
+++ b/compiler-rt/test/hwasan/TestCases/longjmp.c
@@ -3,24 +3,34 @@
// REQUIRES: stable-runtime, pointer-tagging
+#include <setjmp.h>
#include <stdlib.h>
#include <assert.h>
#include <sanitizer/hwasan_interface.h>
+#include <unistd.h>
+
+static int *volatile p;
__attribute__((noinline))
-int f(void *caller_frame) {
+int f(jmp_buf buf) {
int z = 0;
- int *volatile p = &z;
+ p = &z;
// Tag of local is never zero.
assert(__hwasan_tag_pointer(p, 0) != p);
#ifndef NEGATIVE
- // This will destroy shadow of "z", and the following load will crash.
- __hwasan_handle_longjmp(caller_frame);
+ // This will destroy shadow of "z", the p[0] in main will crash.
+ longjmp(buf, 1);
#endif
return p[0];
}
int main() {
- return f(__builtin_frame_address(0));
- // CHECK: READ of size 8 at {{.*}} tags: {{.*}}/00 (ptr/mem)
+ jmp_buf buf;
+ if (setjmp(buf)) {
+ return p[0];
+ } else {
+ f(buf);
+ }
+ return 0;
+ // CHECK: READ of size 4 at {{.*}} tags: {{.*}}/00 (ptr/mem)
}
More information about the llvm-commits
mailing list