[libc-commits] [libc] fedb9fd - [libc] Fix sendmsg iovec unpoisoning (#115057)
via libc-commits
libc-commits at lists.llvm.org
Tue Nov 5 13:35:00 PST 2024
Author: Michael Jones
Date: 2024-11-05T13:34:57-08:00
New Revision: fedb9fdb98314ff0ddff065dbd6ef8b2b7e6ec96
URL: https://github.com/llvm/llvm-project/commit/fedb9fdb98314ff0ddff065dbd6ef8b2b7e6ec96
DIFF: https://github.com/llvm/llvm-project/commit/fedb9fdb98314ff0ddff065dbd6ef8b2b7e6ec96.diff
LOG: [libc] Fix sendmsg iovec unpoisoning (#115057)
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.
Added:
Modified:
libc/src/sys/socket/linux/recvmsg.cpp
Removed:
################################################################################
diff --git a/libc/src/sys/socket/linux/recvmsg.cpp b/libc/src/sys/socket/linux/recvmsg.cpp
index 60bbc84877b850..e42b6346f330a0 100644
--- a/libc/src/sys/socket/linux/recvmsg.cpp
+++ b/libc/src/sys/socket/linux/recvmsg.cpp
@@ -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);
@@ -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);
More information about the libc-commits
mailing list