[compiler-rt] r273174 - Hide send/sendto/sendmsg interptors under a flag.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 10:57:52 PDT 2016
Author: eugenis
Date: Mon Jun 20 12:57:51 2016
New Revision: 273174
URL: http://llvm.org/viewvc/llvm-project?rev=273174&view=rev
Log:
Hide send/sendto/sendmsg interptors under a flag.
A runtime flag to enable checking in send* interceptors.
Checking is enabled by default.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.inc
compiler-rt/trunk/test/asan/TestCases/Linux/recvfrom.cc
compiler-rt/trunk/test/msan/Linux/sendmsg.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=273174&r1=273173&r2=273174&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Mon Jun 20 12:57:51 2016
@@ -2521,7 +2521,8 @@ INTERCEPTOR(SSIZE_T, sendmsg, int fd, st
COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
}
SSIZE_T res = REAL(sendmsg)(fd, msg, flags);
- if (res >= 0 && msg) read_msghdr(ctx, msg, res);
+ if (common_flags()->intercept_send && res >= 0 && msg)
+ read_msghdr(ctx, msg, res);
return res;
}
#define INIT_SENDMSG COMMON_INTERCEPT_FUNCTION(sendmsg);
@@ -5623,7 +5624,8 @@ INTERCEPTOR(SSIZE_T, send, int fd, void
COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
}
SSIZE_T res = REAL(send)(fd, buf, len, flags);
- if (res > 0) COMMON_INTERCEPTOR_READ_RANGE(ctx, buf, Min((SIZE_T)res, len));
+ if (common_flags()->intercept_send && res > 0)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, buf, Min((SIZE_T)res, len));
return res;
}
@@ -5635,9 +5637,11 @@ INTERCEPTOR(SSIZE_T, sendto, int fd, voi
COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd);
COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd);
}
- if (srcaddr && addrlen) COMMON_INTERCEPTOR_READ_RANGE(ctx, srcaddr, addrlen);
+ if (common_flags()->intercept_send && srcaddr && addrlen)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, srcaddr, addrlen);
SSIZE_T res = REAL(sendto)(fd, buf, len, flags, srcaddr, addrlen);
- if (res > 0) COMMON_INTERCEPTOR_READ_RANGE(ctx, buf, Min((SIZE_T)res, len));
+ if (common_flags()->intercept_send && res > 0)
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, buf, Min((SIZE_T)res, len));
return res;
}
#define INIT_SEND_SENDTO \
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.inc?rev=273174&r1=273173&r2=273174&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.inc Mon Jun 20 12:57:51 2016
@@ -205,6 +205,9 @@ COMMON_FLAG(bool, intercept_intrin, true
COMMON_FLAG(bool, intercept_stat, true,
"If set, uses custom wrappers for *stat functions "
"to find more errors.")
+COMMON_FLAG(bool, intercept_send, true,
+ "If set, uses custom wrappers for send* functions "
+ "to find more errors.")
COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
"mappings in /proc/self/maps with "
"user-readable names")
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/recvfrom.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/recvfrom.cc?rev=273174&r1=273173&r2=273174&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/recvfrom.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/recvfrom.cc Mon Jun 20 12:57:51 2016
@@ -2,6 +2,7 @@
//
// RUN: %clangxx_asan %s -DRECVFROM -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RECVFROM
// RUN: %clangxx_asan %s -DSENDTO -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SENDTO
+// RUN: %clangxx_asan %s -DSENDTO -o %t && %env_asan_opts=intercept_send=0 %run %t 2>&1
//
// UNSUPPORTED: android
Modified: compiler-rt/trunk/test/msan/Linux/sendmsg.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/Linux/sendmsg.cc?rev=273174&r1=273173&r2=273174&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/Linux/sendmsg.cc (original)
+++ compiler-rt/trunk/test/msan/Linux/sendmsg.cc Mon Jun 20 12:57:51 2016
@@ -10,6 +10,13 @@
// RUN: %clangxx_msan %s -DSENDTO -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
// RUN: %clangxx_msan %s -DSENDMSG -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
+// RUN: %clangxx_msan %s -DSEND -DBUF -o %t && \
+// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
+// RUN: %clangxx_msan %s -DSENDTO -DBUF -o %t && \
+// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
+// RUN: %clangxx_msan %s -DSENDMSG -DBUF -o %t && \
+// RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE
+
// UNSUPPORTED: android
#include <assert.h>
More information about the llvm-commits
mailing list