150
|
1 // RUN: %clang_hwasan -g %s -o %t && not %run %t 2>&1 | FileCheck %s
|
|
2 // Only implemented for interceptor ABI on AArch64.
|
|
3 // REQUIRES: aarch64-target-arch
|
|
4
|
|
5 #include <setjmp.h>
|
|
6 #include <stdio.h>
|
|
7
|
|
8 /* Testing longjmp/setjmp should test that accesses to scopes jmp'd over are
|
|
9 caught. */
|
|
10 int __attribute__((noinline))
|
|
11 uses_longjmp(int **other_array, int num, jmp_buf env) {
|
|
12 int internal_array[100] = {0};
|
|
13 *other_array = &internal_array[0];
|
|
14 if (num % 2)
|
|
15 longjmp(env, num);
|
|
16 else
|
|
17 return num % 8;
|
|
18 }
|
|
19
|
|
20 int __attribute__((noinline)) uses_setjmp(int num) {
|
|
21 int big_array[100];
|
|
22 int *other_array = NULL;
|
|
23 sigjmp_buf cur_env;
|
|
24 int temp = 0;
|
|
25 if ((temp = sigsetjmp(cur_env, 1)) != 0) {
|
|
26 // We're testing that our longjmp interceptor untagged the previous stack.
|
|
27 // Hence the tag in memory should be zero.
|
|
28 if (other_array != NULL)
|
|
29 return other_array[0];
|
|
30 // CHECK: READ of size 4 at{{.*}}tags: {{..}}/00
|
|
31 return 100;
|
|
32 } else
|
|
33 return uses_longjmp(&other_array, num, cur_env);
|
|
34 }
|
|
35
|
|
36 int __attribute__((noinline)) main() {
|
|
37 uses_setjmp(1);
|
|
38 return 0;
|
|
39 }
|