summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-06-24 21:15:53 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-06-24 21:15:53 +0000
commitc7509de7cc2674e3c60d4fbc5d0700282db10574 (patch)
treeb3a81a6125dde801ff12e3b518af7e7e0d78b28d
parent0399226cf9b4a0684549973eb64775d617137d5d (diff)
downloadbcm5719-llvm-c7509de7cc2674e3c60d4fbc5d0700282db10574.tar.gz
bcm5719-llvm-c7509de7cc2674e3c60d4fbc5d0700282db10574.zip
[msan] Fix syscall handlers for pipe, pipe2, socketpair.
These syscalls write two file descriptors into the output buffer, not one. llvm-svn: 273728
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc20
-rw-r--r--compiler-rt/test/msan/Linux/syscalls.cc14
2 files changed, 21 insertions, 13 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_syscalls.inc
index 9932f1e7630..48016f218f3 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 78dba36638a..c5ac3e27fa1 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;
}
OpenPOWER on IntegriCloud