[libc-commits] [libc] [libc] More unpoison for recvmsg (PR #117347)
via libc-commits
libc-commits at lists.llvm.org
Fri Nov 22 08:53:37 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Michael Jones (michaelrj-google)
<details>
<summary>Changes</summary>
The msghdr struct is very nested which makes it a pain to unpoison. I'm
pretty sure I've got all of it now. I also added a test which should
hopefully exercise the iovec part under sanitizers since I suspect
that's what's been causing issues.
---
Full diff: https://github.com/llvm/llvm-project/pull/117347.diff
2 Files Affected:
- (modified) libc/src/sys/socket/linux/recvmsg.cpp (+1)
- (modified) libc/test/src/sys/socket/linux/sendmsg_recvmsg_test.cpp (+2)
``````````diff
diff --git a/libc/src/sys/socket/linux/recvmsg.cpp b/libc/src/sys/socket/linux/recvmsg.cpp
index e42b6346f330a0..647beeede07f57 100644
--- a/libc/src/sys/socket/linux/recvmsg.cpp
+++ b/libc/src/sys/socket/linux/recvmsg.cpp
@@ -41,6 +41,7 @@ LLVM_LIBC_FUNCTION(ssize_t, recvmsg, (int sockfd, msghdr *msg, int flags)) {
// Unpoison the msghdr, as well as all its components.
MSAN_UNPOISON(msg, sizeof(msghdr));
MSAN_UNPOISON(msg->msg_name, msg->msg_namelen);
+ MSAN_UNPOISON(msg->msg_iov, msg->msg_iovlen * sizeof(struct iovec));
for (size_t i = 0; i < msg->msg_iovlen; ++i) {
MSAN_UNPOISON(msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
diff --git a/libc/test/src/sys/socket/linux/sendmsg_recvmsg_test.cpp b/libc/test/src/sys/socket/linux/sendmsg_recvmsg_test.cpp
index abcb0a3e6e5062..4d3bae1bfe142a 100644
--- a/libc/test/src/sys/socket/linux/sendmsg_recvmsg_test.cpp
+++ b/libc/test/src/sys/socket/linux/sendmsg_recvmsg_test.cpp
@@ -64,6 +64,8 @@ TEST(LlvmLibcSendMsgRecvMsgTest, SucceedsWithSocketPair) {
ASSERT_EQ(recv_result, static_cast<ssize_t>(MESSAGE_LEN));
ASSERT_ERRNO_SUCCESS();
+ ASSERT_EQ(recv_message.msg_iov->iov_base, reinterpret_cast<void *>(buffer));
+
ASSERT_STREQ(buffer, TEST_MESSAGE);
// close both ends of the socket
``````````
</details>
https://github.com/llvm/llvm-project/pull/117347
More information about the libc-commits
mailing list