File tree Expand file tree Collapse file tree 3 files changed +43
-9
lines changed
Expand file tree Collapse file tree 3 files changed +43
-9
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,10 @@ struct HWAsanInterceptorContext {
3636 const char *interceptor_name;
3737};
3838
39- # define ACCESS_MEMORY_RANGE (offset, size, access ) \
40- do { \
41- __hwasan::CheckAddressSized<ErrorAction::Abort , access>((uptr)offset, \
42- size); \
39+ # define ACCESS_MEMORY_RANGE (offset, size, access ) \
40+ do { \
41+ __hwasan::CheckAddressSized<ErrorAction::Recover , access>((uptr)offset, \
42+ size); \
4343 } while (0 )
4444
4545# define HWASAN_READ_RANGE (offset, size ) \
@@ -74,9 +74,8 @@ struct HWAsanInterceptorContext {
7474
7575# if HWASAN_WITH_INTERCEPTORS
7676
77- # define COMMON_SYSCALL_PRE_READ_RANGE (p, s ) __hwasan_loadN((uptr)p, (uptr)s)
78- # define COMMON_SYSCALL_PRE_WRITE_RANGE (p, s ) \
79- __hwasan_storeN ((uptr)p, (uptr)s)
77+ # define COMMON_SYSCALL_PRE_READ_RANGE (p, s ) HWASAN_READ_RANGE(p, s)
78+ # define COMMON_SYSCALL_PRE_WRITE_RANGE (p, s ) HWASAN_WRITE_RANGE(p, s)
8079# define COMMON_SYSCALL_POST_READ_RANGE (p, s ) \
8180 do { \
8281 (void )(p); \
Original file line number Diff line number Diff line change 1- // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s
2- // RUN: %clangxx_hwasan -O3 %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s
1+ // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
2+ // RUN: %clangxx_hwasan -O3 %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
3+ // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=0:symbolize=0 %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
34
45// UNSUPPORTED: android
56
@@ -29,5 +30,7 @@ int main(int argc, char *argv[]) {
2930 // CHECK: [[PTR]] is located 1 bytes before a 1000-byte region
3031
3132 free (buf);
33+ fprintf (stderr, " RETURN_FROM_TEST\n " );
34+ // RECOVER: RETURN_FROM_TEST
3235 return 0 ;
3336}
Original file line number Diff line number Diff line change 1+ // RUN: %clangxx_hwasan %s -o %t
2+ // RUN: %env_hwasan_opts=halt_on_error=0 not %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
3+ // RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
4+
5+ #include < sanitizer/hwasan_interface.h>
6+ #include < stdio.h>
7+ #include < stdlib.h>
8+ #include < string.h>
9+ #include < unistd.h>
10+
11+ __attribute__ ((no_sanitize(" hwaddress" ))) void
12+ ForceCallInterceptor(void *p, int c, size_t size) {
13+ memset (p, c, size) == nullptr ;
14+ }
15+
16+ int main (int argc, char **argv) {
17+ __hwasan_enable_allocator_tagging ();
18+ char a[] = {static_cast <char >(argc), 2 , 3 , 4 };
19+ int size = sizeof (a);
20+ char *volatile p = (char *)malloc (size);
21+ void *volatile p2 = p;
22+ for (int i = 0 ; p2 == p; p2 = __hwasan_tag_pointer (p, ++i)) {
23+ }
24+ ForceCallInterceptor (p2, 0 , size);
25+ free (p);
26+ fprintf (stderr, " RETURN_FROM_TEST\n " );
27+ return 0 ;
28+ // CHECK: HWAddressSanitizer: tag-mismatch on address
29+ // CHECK: WRITE of size 4
30+ // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memset-recover.cpp:[[@LINE-28]]
31+ // RECOVER: RETURN_FROM_TEST
32+ }
You can’t perform that action at this time.
0 commit comments