Skip to content

Commit

Permalink
[libc] Fix sendmsg iovec unpoisoning (#115057)
Browse files Browse the repository at this point in the history
The unpoisoning for sendmsg had a typo where it would not unpoison all
of the elements in the iovec, causing msan errors. This patch fixes
that.
  • Loading branch information
michaelrj-google authored Nov 5, 2024
1 parent 97262af commit fedb9fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libc/src/sys/socket/linux/recvmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(ssize_t, recvmsg,
(int sockfd, struct msghdr *msg, int flags)) {
LLVM_LIBC_FUNCTION(ssize_t, recvmsg, (int sockfd, msghdr *msg, int flags)) {
#ifdef SYS_recvmsg
ssize_t ret =
LIBC_NAMESPACE::syscall_impl<ssize_t>(SYS_recvmsg, sockfd, msg, flags);
Expand All @@ -40,9 +39,11 @@ LLVM_LIBC_FUNCTION(ssize_t, recvmsg,
}

// Unpoison the msghdr, as well as all its components.
MSAN_UNPOISON(msg, sizeof(msghdr));
MSAN_UNPOISON(msg->msg_name, msg->msg_namelen);

for (size_t i = 0; i < msg->msg_iovlen; ++i) {
MSAN_UNPOISON(msg->msg_iov->iov_base, msg->msg_iov->iov_len);
MSAN_UNPOISON(msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
}
MSAN_UNPOISON(msg->msg_control, msg->msg_controllen);

Expand Down

0 comments on commit fedb9fd

Please sign in to comment.