diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-04-08 13:45:12 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-04-08 13:45:12 +0000 |
| commit | b4eac2f81046feb6bf5b4ba6819f31f8f6424784 (patch) | |
| tree | 59a397d7af9614df14d9e268e72aed72d863189e | |
| parent | d66c414619a7a3b4893c6730d2d9ebc859d1f23f (diff) | |
| download | bcm5719-llvm-b4eac2f81046feb6bf5b4ba6819f31f8f6424784.tar.gz bcm5719-llvm-b4eac2f81046feb6bf5b4ba6819f31f8f6424784.zip | |
[msan] Interceptors for pipe2 and socketpair.
llvm-svn: 179022
| -rw-r--r-- | compiler-rt/lib/msan/msan_interceptors.cc | 18 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/tests/msan_test.cc | 21 |
2 files changed, 39 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc index 1dafc5d6c63..b1caf0e73b2 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cc +++ b/compiler-rt/lib/msan/msan_interceptors.cc @@ -540,6 +540,22 @@ INTERCEPTOR(int, pipe, int pipefd[2]) { return res; } +INTERCEPTOR(int, pipe2, int pipefd[2], int flags) { + ENSURE_MSAN_INITED(); + int res = REAL(pipe2)(pipefd, flags); + if (!res) + __msan_unpoison(pipefd, sizeof(int[2])); + return res; +} + +INTERCEPTOR(int, socketpair, int domain, int type, int protocol, int sv[2]) { + ENSURE_MSAN_INITED(); + int res = REAL(socketpair)(domain, type, protocol, sv); + if (!res) + __msan_unpoison(sv, sizeof(int[2])); + return res; +} + INTERCEPTOR(int, wait, int *status) { ENSURE_MSAN_INITED(); int res = REAL(wait)(status); @@ -1109,6 +1125,8 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(__xstat64); INTERCEPT_FUNCTION(__lxstat64); INTERCEPT_FUNCTION(pipe); + INTERCEPT_FUNCTION(pipe2); + INTERCEPT_FUNCTION(socketpair); INTERCEPT_FUNCTION(wait); INTERCEPT_FUNCTION(waitpid); INTERCEPT_FUNCTION(fgets); diff --git a/compiler-rt/lib/msan/tests/msan_test.cc b/compiler-rt/lib/msan/tests/msan_test.cc index d7c1de0fe1c..6ab08496824 100644 --- a/compiler-rt/lib/msan/tests/msan_test.cc +++ b/compiler-rt/lib/msan/tests/msan_test.cc @@ -41,6 +41,7 @@ #include <sys/types.h> #include <dirent.h> #include <pwd.h> +#include <sys/socket.h> #if defined(__i386__) || defined(__x86_64__) # include <emmintrin.h> @@ -605,6 +606,26 @@ TEST(MemorySanitizer, pipe) { close(pipefd[1]); } +TEST(MemorySanitizer, pipe2) { + int* pipefd = new int[2]; + int res = pipe2(pipefd, O_NONBLOCK); + assert(!res); + EXPECT_NOT_POISONED(pipefd[0]); + EXPECT_NOT_POISONED(pipefd[1]); + close(pipefd[0]); + close(pipefd[1]); +} + +TEST(MemorySanitizer, socketpair) { + int sv[2]; + int res = socketpair(AF_UNIX, SOCK_STREAM, 0, sv); + assert(!res); + EXPECT_NOT_POISONED(sv[0]); + EXPECT_NOT_POISONED(sv[1]); + close(sv[0]); + close(sv[1]); +} + TEST(MemorySanitizer, getcwd) { char path[PATH_MAX + 1]; char* res = getcwd(path, sizeof(path)); |

