forked from OSchip/llvm-project
[msan] Fix syscall handlers for pipe, pipe2, socketpair.
These syscalls write two file descriptors into the output buffer, not one. llvm-svn: 273728
This commit is contained in:
parent
0399226cf9
commit
c7509de7cc
|
@ -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) {}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue