Skip to content

Commit 3e5187e

Browse files
committed
Revert "[HWASAN] Enable memcpy, memmove and memset interceptors (#70387)"
Breaks build bots, details in #70387. This reverts commit 91cdd7d.
1 parent a5403a3 commit 3e5187e

File tree

7 files changed

+40
-125
lines changed

7 files changed

+40
-125
lines changed

compiler-rt/lib/hwasan/hwasan_interceptors.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ struct HWAsanInterceptorContext {
9090
# include "sanitizer_common/sanitizer_syscalls_netbsd.inc"
9191

9292
# define COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ptr, size) \
93-
HWASAN_WRITE_RANGE(ctx, ptr, size)
93+
do { \
94+
} while (false)
9495

9596
# define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
9697
HWASAN_READ_RANGE(ctx, ptr, size)
@@ -146,6 +147,30 @@ struct HWAsanInterceptorContext {
146147
(void)(name); \
147148
} while (false)
148149

150+
# define COMMON_INTERCEPTOR_MEMMOVE_IMPL(ctx, to, from, size) \
151+
do { \
152+
(void)(ctx); \
153+
(void)(to); \
154+
(void)(from); \
155+
(void)(size); \
156+
} while (false)
157+
158+
# define COMMON_INTERCEPTOR_MEMCPY_IMPL(ctx, to, from, size) \
159+
do { \
160+
(void)(ctx); \
161+
(void)(to); \
162+
(void)(from); \
163+
(void)(size); \
164+
} while (false)
165+
166+
# define COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, block, c, size) \
167+
do { \
168+
(void)(ctx); \
169+
(void)(block); \
170+
(void)(c); \
171+
(void)(size); \
172+
} while (false)
173+
149174
# define COMMON_INTERCEPTOR_STRERROR() \
150175
do { \
151176
} while (false)

compiler-rt/lib/hwasan/hwasan_platform_interceptors.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@
5656
#undef SANITIZER_INTERCEPT_STRCASECMP
5757
#define SANITIZER_INTERCEPT_STRCASECMP 0
5858

59-
// #undef SANITIZER_INTERCEPT_MEMSET
60-
// #define SANITIZER_INTERCEPT_MEMSET 0
59+
#undef SANITIZER_INTERCEPT_MEMSET
60+
#define SANITIZER_INTERCEPT_MEMSET 0
6161

62-
// #undef SANITIZER_INTERCEPT_MEMMOVE
63-
// #define SANITIZER_INTERCEPT_MEMMOVE 0
62+
#undef SANITIZER_INTERCEPT_MEMMOVE
63+
#define SANITIZER_INTERCEPT_MEMMOVE 0
6464

65-
// #undef SANITIZER_INTERCEPT_MEMCPY
66-
// #define SANITIZER_INTERCEPT_MEMCPY 0
65+
#undef SANITIZER_INTERCEPT_MEMCPY
66+
#define SANITIZER_INTERCEPT_MEMCPY 0
6767

6868
// #undef SANITIZER_INTERCEPT_MEMCMP
6969
// #define SANITIZER_INTERCEPT_MEMCMP 0

compiler-rt/test/hwasan/TestCases/bcmp.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,25 @@
44
// RUN: %clangxx_hwasan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
55
// REQUIRES: !android
66

7-
#include <assert.h>
87
#include <sanitizer/hwasan_interface.h>
98
#include <stdlib.h>
109
#include <string.h>
1110
#include <unistd.h>
1211

13-
__attribute__((no_sanitize("hwaddress"))) void
14-
ForceCallInterceptor(void *p, const void *a, size_t size) {
15-
assert(bcmp(p, a, size) == 0);
16-
}
17-
1812
int main(int argc, char **argv) {
1913
__hwasan_enable_allocator_tagging();
2014
char a[] = {static_cast<char>(argc), 2, 3, 4};
2115
int size = sizeof(a);
2216
char *p = (char *)malloc(size);
2317
memcpy(p, a, size);
2418
free(p);
25-
ForceCallInterceptor(p, a, size);
26-
return 0;
19+
return bcmp(p, a, size);
2720
// CHECK: HWAddressSanitizer: tag-mismatch on address
2821
// CHECK: READ of size 4
29-
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-4]]
22+
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-3]]
3023
// CHECK: Cause: use-after-free
3124
// CHECK: freed by thread
32-
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-8]]
25+
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-7]]
3326
// CHECK: previously allocated by thread
34-
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-12]]
27+
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}bcmp.cpp:[[@LINE-11]]
3528
}

compiler-rt/test/hwasan/TestCases/memcmp.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@
33
// RUN: %clangxx_hwasan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
44
// RUN: %clangxx_hwasan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
55

6-
#include <assert.h>
76
#include <sanitizer/hwasan_interface.h>
87
#include <stdlib.h>
98
#include <string.h>
109
#include <unistd.h>
1110

12-
__attribute__((no_sanitize("hwaddress"))) void
13-
ForceCallInterceptor(void *p, const void *a, size_t size) {
14-
assert(memcmp(p, a, size) == 0);
15-
}
16-
1711
int main(int argc, char **argv) {
1812
__hwasan_enable_allocator_tagging();
1913
char a[] = {static_cast<char>(argc), 2, 3, 4};
2014
int size = sizeof(a);
2115
char *p = (char *)malloc(size);
2216
memcpy(p, a, size);
2317
free(p);
24-
ForceCallInterceptor(p, a, size);
25-
return 0;
18+
return memcmp(p, a, size);
2619
// CHECK: HWAddressSanitizer: tag-mismatch on address
2720
// CHECK: READ of size 4
28-
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcmp.cpp:[[@LINE-4]]
21+
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcmp.cpp:[[@LINE-3]]
2922
// CHECK: Cause: use-after-free
3023
// CHECK: freed by thread
31-
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcmp.cpp:[[@LINE-8]]
24+
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcmp.cpp:[[@LINE-7]]
3225
// CHECK: previously allocated by thread
33-
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcmp.cpp:[[@LINE-12]]
26+
// CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memcmp.cpp:[[@LINE-11]]
3427
}

compiler-rt/test/hwasan/TestCases/memcpy.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

compiler-rt/test/hwasan/TestCases/memmove.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

compiler-rt/test/hwasan/TestCases/memset.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)