diff options
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | 9 | ||||
-rw-r--r-- | compiler-rt/test/msan/Linux/sendmsg.cc | 23 |
2 files changed, 11 insertions, 21 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index ae78da2e74b..b7664c4e513 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -5639,16 +5639,15 @@ INTERCEPTOR(SSIZE_T, send, int fd, void *buf, SIZE_T len, int flags) { } INTERCEPTOR(SSIZE_T, sendto, int fd, void *buf, SIZE_T len, int flags, - void *srcaddr, int addrlen) { + void *dstaddr, int addrlen) { void *ctx; - COMMON_INTERCEPTOR_ENTER(ctx, sendto, fd, buf, len, flags, srcaddr, addrlen); + COMMON_INTERCEPTOR_ENTER(ctx, sendto, fd, buf, len, flags, dstaddr, addrlen); if (fd >= 0) { COMMON_INTERCEPTOR_FD_ACCESS(ctx, fd); COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd); } - 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); + // Can't check dstaddr as it may have uninitialized padding at the end. + SSIZE_T res = REAL(sendto)(fd, buf, len, flags, dstaddr, addrlen); if (common_flags()->intercept_send && res > 0) COMMON_INTERCEPTOR_READ_RANGE(ctx, buf, Min((SIZE_T)res, len)); return res; diff --git a/compiler-rt/test/msan/Linux/sendmsg.cc b/compiler-rt/test/msan/Linux/sendmsg.cc index 2f5600729f0..6a8ef83c118 100644 --- a/compiler-rt/test/msan/Linux/sendmsg.cc +++ b/compiler-rt/test/msan/Linux/sendmsg.cc @@ -1,20 +1,16 @@ -// RUN: %clangxx_msan %s -DSEND -DBUF -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SEND -// RUN: %clangxx_msan %s -DSENDTO -DBUF -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SENDTO -// RUN: %clangxx_msan %s -DSENDMSG -DBUF -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SENDMSG - -// FIXME: intercept connect() and add a SEND+ADDR test -// RUN: %clangxx_msan %s -DSENDTO -DADDR -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SENDTO-ADDR -// RUN: %clangxx_msan %s -DSENDMSG -DADDR -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SENDMSG-ADDR +// RUN: %clangxx_msan %s -DSEND -DPOISON -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SEND +// RUN: %clangxx_msan %s -DSENDTO -DPOISON -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SENDTO +// RUN: %clangxx_msan %s -DSENDMSG -DPOISON -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=SENDMSG // RUN: %clangxx_msan %s -DSEND -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE // 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: %clangxx_msan %s -DSEND -DPOISON -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: %clangxx_msan %s -DSENDTO -DPOISON -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: %clangxx_msan %s -DSENDMSG -DPOISON -o %t && \ // RUN: MSAN_OPTIONS=intercept_send=0 %run %t 2>&1 | FileCheck %s --check-prefix=NEGATIVE // UNSUPPORTED: android @@ -49,10 +45,7 @@ int main() { socklen_t addrlen = sizeof(serveraddr); getsockname(sockfd, (struct sockaddr *)&serveraddr, &addrlen); -#if defined(ADDR) - assert(addrlen > 3); - __msan_poison(((char *)&serveraddr) + 3, 1); -#elif defined(BUF) +#if defined(POISON) __msan_poison(buf + 7, 1); #endif @@ -78,12 +71,10 @@ int main() { ret = sendto(sockfd, buf, kBufSize, 0, (struct sockaddr *)&serveraddr, addrlen); // SENDTO: Uninitialized bytes in __interceptor_sendto at offset 7 inside [{{.*}}, 10) - // SENDTO-ADDR: Uninitialized bytes in __interceptor_sendto at offset 3 inside [{{.*}}, assert(ret > 0); #elif defined(SENDMSG) ret = sendmsg(sockfd, &msg, 0); // SENDMSG: Uninitialized bytes in {{.*}} at offset 2 inside [{{.*}}, 5) - // SENDMSG-ADDR: Uninitialized bytes in {{.*}} at offset 3 inside [{{.*}}, assert(ret > 0); #endif fprintf(stderr, "== done\n"); |