[libc-commits] [libc] [libc] Fix sendmsg iovec unpoisoning (PR #115057)

via libc-commits libc-commits at lists.llvm.org
Tue Nov 5 12:27:22 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/115057.diff


1 Files Affected:

- (modified) libc/src/sys/socket/linux/recvmsg.cpp (+3-1) 


``````````diff
diff --git a/libc/src/sys/socket/linux/recvmsg.cpp b/libc/src/sys/socket/linux/recvmsg.cpp
index 60bbc84877b850..43929da87e16d2 100644
--- a/libc/src/sys/socket/linux/recvmsg.cpp
+++ b/libc/src/sys/socket/linux/recvmsg.cpp
@@ -40,9 +40,11 @@ LLVM_LIBC_FUNCTION(ssize_t, recvmsg,
   }
 
   // Unpoison the msghdr, as well as all its components.
+  MSAN_UNPOISON(msg, sizeof(struct 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);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/115057


More information about the libc-commits mailing list