All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] linux-user/syscall: zero-init msghdr in do_sendrecvmsg_locked
@ 2021-05-16  9:15 Kenta Iwasaki
  2021-05-16 10:53 ` Laurent Vivier
  0 siblings, 1 reply; 7+ messages in thread
From: Kenta Iwasaki @ 2021-05-16  9:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent, Kenta Iwasaki

The mixing of libc and kernel versions of the layout of the `msghdr`
struct causes EMSGSIZE to be returned by sendmsg if the `msghdr` struct
is not zero-initialized (such that padding bytes comprise of
uninitialized memory).

Other parts of the QEMU codebase appear to zero-initialize the `msghdr`
struct to workaround these struct layout issues, except for
do_sendrecvmsg_locked in linux-user/syscall.c.

This patch zero-initializes the `msghdr` struct in
do_sendrecvmsg_locked.

Signed-off-by: Kenta Iwasaki <kenta@lithdew.net>
---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 95d79ddc43..f60b7e04d5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3337,7 +3337,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
                                       int flags, int send)
 {
     abi_long ret, len;
-    struct msghdr msg;
+    struct msghdr msg = { 0 };
     abi_ulong count;
     struct iovec *vec;
     abi_ulong target_vec;
-- 
2.31.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-20 16:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16  9:15 [PATCH] linux-user/syscall: zero-init msghdr in do_sendrecvmsg_locked Kenta Iwasaki
2021-05-16 10:53 ` Laurent Vivier
2021-05-16 12:57   ` Kenta Iwasaki
2021-05-23 21:44     ` Kenta Iwasaki
2021-06-20 14:56     ` Laurent Vivier
2021-06-20 15:09       ` Kenta Iwasaki
2021-06-20 16:45         ` Laurent Vivier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.