summaryrefslogtreecommitdiff
path: root/lib/asan/asan_interceptors.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-07-29 23:53:08 +0000
committerKostya Serebryany <kcc@google.com>2015-07-29 23:53:08 +0000
commita0177fee07dfcf0a210a7a4c6454f59ff46b6135 (patch)
tree3bcee635045c72e4b0a287e34194f4f461d8ef2e /lib/asan/asan_interceptors.cc
parent1543b2d47723f3170b6493536843021486728e20 (diff)
downloadcompiler-rt-a0177fee07dfcf0a210a7a4c6454f59ff46b6135.tar.gz
[asan,tsan,msan] move the memcmp interceptor from asan/tsan to sanitizer_common. This may potentially lead to more reports from msan as it now sees the reads inside memcmp. To disable, use the flag intercept_memcmp=0. Likewise, it may potentially cause new races to appear due to more strict memcmp checking (flag strict_memcmp=1)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@243595 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_interceptors.cc')
-rw-r--r--lib/asan/asan_interceptors.cc35
1 files changed, 0 insertions, 35 deletions
diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc
index d8b48d391..c1357f4ab 100644
--- a/lib/asan/asan_interceptors.cc
+++ b/lib/asan/asan_interceptors.cc
@@ -363,40 +363,6 @@ INTERCEPTOR(void, __cxa_throw, void *a, void *b, void *c) {
}
#endif
-static inline int CharCmp(unsigned char c1, unsigned char c2) {
- return (c1 == c2) ? 0 : (c1 < c2) ? -1 : 1;
-}
-
-INTERCEPTOR(int, memcmp, const void *a1, const void *a2, uptr size) {
- void *ctx;
- ASAN_INTERCEPTOR_ENTER(ctx, memcmp);
- if (UNLIKELY(!asan_inited)) return internal_memcmp(a1, a2, size);
- ENSURE_ASAN_INITED();
- if (flags()->replace_intrin) {
- if (flags()->strict_memcmp) {
- // Check the entire regions even if the first bytes of the buffers are
- // different.
- ASAN_READ_RANGE(ctx, a1, size);
- ASAN_READ_RANGE(ctx, a2, size);
- // Fallthrough to REAL(memcmp) below.
- } else {
- unsigned char c1 = 0, c2 = 0;
- const unsigned char *s1 = (const unsigned char*)a1;
- const unsigned char *s2 = (const unsigned char*)a2;
- uptr i;
- for (i = 0; i < size; i++) {
- c1 = s1[i];
- c2 = s2[i];
- if (c1 != c2) break;
- }
- ASAN_READ_RANGE(ctx, s1, Min(i + 1, size));
- ASAN_READ_RANGE(ctx, s2, Min(i + 1, size));
- return CharCmp(c1, c2);
- }
- }
- return REAL(memcmp(a1, a2, size));
-}
-
// memcpy is called during __asan_init() from the internals of printf(...).
// We do not treat memcpy with to==from as a bug.
// See http://llvm.org/bugs/show_bug.cgi?id=11763.
@@ -767,7 +733,6 @@ void InitializeAsanInterceptors() {
InitializeCommonInterceptors();
// Intercept mem* functions.
- ASAN_INTERCEPT_FUNC(memcmp);
ASAN_INTERCEPT_FUNC(memmove);
ASAN_INTERCEPT_FUNC(memset);
if (PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE) {