diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc index 9932f1e76306..48016f218f3d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc @@ -1237,17 +1237,15 @@ POST_SYSCALL(fcntl64)(long res, long fd, long cmd, long arg) {} PRE_SYSCALL(pipe)(void *fildes) {} POST_SYSCALL(pipe)(long res, void *fildes) { - if (res >= 0) { - if (fildes) POST_WRITE(fildes, sizeof(int)); - } + if (res >= 0) + if (fildes) POST_WRITE(fildes, sizeof(int) * 2); } PRE_SYSCALL(pipe2)(void *fildes, long flags) {} POST_SYSCALL(pipe2)(long res, void *fildes, long flags) { - if (res >= 0) { - if (fildes) POST_WRITE(fildes, sizeof(int)); - } + if (res >= 0) + if (fildes) POST_WRITE(fildes, sizeof(int) * 2); } PRE_SYSCALL(dup)(long fildes) {} @@ -1880,13 +1878,11 @@ PRE_SYSCALL(socket)(long arg0, long arg1, long arg2) {} POST_SYSCALL(socket)(long res, long arg0, long arg1, long arg2) {} -PRE_SYSCALL(socketpair)(long arg0, long arg1, long arg2, void *arg3) {} +PRE_SYSCALL(socketpair)(long arg0, long arg1, long arg2, int *sv) {} -POST_SYSCALL(socketpair)(long res, long arg0, long arg1, long arg2, - void *arg3) { - if (res >= 0) { - if (arg3) POST_WRITE(arg3, sizeof(int)); - } +POST_SYSCALL(socketpair)(long res, long arg0, long arg1, long arg2, int *sv) { + if (res >= 0) + if (sv) POST_WRITE(sv, sizeof(int) * 2); } PRE_SYSCALL(socketcall)(long call, void *args) {} diff --git a/compiler-rt/test/msan/Linux/syscalls.cc b/compiler-rt/test/msan/Linux/syscalls.cc index 78dba36638a6..c5ac3e27fa11 100644 --- a/compiler-rt/test/msan/Linux/syscalls.cc +++ b/compiler-rt/test/msan/Linux/syscalls.cc @@ -19,7 +19,7 @@ sanity of their behaviour. */ int main(int argc, char *argv[]) { - char buf[1000]; + char buf[1000] __attribute__((aligned(8))); const int kTen = 10; const int kFortyTwo = 42; memset(buf, 0, sizeof(buf)); @@ -111,5 +111,17 @@ int main(int argc, char *argv[]) { assert(__msan_test_shadow(&p, sizeof(p)) == -1); assert(__msan_test_shadow(buf, sizeof(buf)) >= 32); + __msan_poison(buf, sizeof(buf)); + __sanitizer_syscall_post_pipe(0, (int *)buf); + assert(__msan_test_shadow(buf, sizeof(buf)) == 2 * sizeof(int)); + + __msan_poison(buf, sizeof(buf)); + __sanitizer_syscall_post_pipe2(0, (int *)buf, 0); + assert(__msan_test_shadow(buf, sizeof(buf)) == 2 * sizeof(int)); + + __msan_poison(buf, sizeof(buf)); + __sanitizer_syscall_post_socketpair(0, 0, 0, 0, (int *)buf); + assert(__msan_test_shadow(buf, sizeof(buf)) == 2 * sizeof(int)); + return 0; }