aboutsummaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2018-07-12 00:12:44 +0200
committerLaurent Vivier <laurent@vivier.eu>2018-07-15 16:04:38 +0200
commit1d3d1b23e1c8f52ec431ddaa8deea1322bc25cbf (patch)
tree7274178813b52a34965a9349f161975b4d2d4af0 /linux-user/syscall.c
parentdc18baaef36d95e5a7b4fbc60daff3d92afe737c (diff)
downloadqemu-1d3d1b23e1c8f52ec431ddaa8deea1322bc25cbf.zip
qemu-1d3d1b23e1c8f52ec431ddaa8deea1322bc25cbf.tar.gz
qemu-1d3d1b23e1c8f52ec431ddaa8deea1322bc25cbf.tar.bz2
Zero out the host's `msg_control` buffer
If this is not done, qemu would drop any control message after the first one. This is because glibc's `CMSG_NXTHDR` macro accesses the uninitialized cmsghdr's length field in order to find out if the message fits into the `msg_control` buffer, wrongly assuming that it doesn't because the length field contains garbage. Accessing the length field is fine for completed messages we receive from the kernel, but is - as far as I know - not needed since the kernel won't return such an invalid cmsghdr in the first place. This is tracked as this glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13500 It's probably also a good idea to bail with an error if `CMSG_NXTHDR` returns NULL but `TARGET_CMSG_NXTHDR` doesn't (ie. we still expect cmsgs). Signed-off-by: Jonas Schievink <jonasschievink@gmail.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180711221244.31869-1-jonasschievink@gmail.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index aa4f3eb..3df3bdf 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3843,6 +3843,8 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
}
msg.msg_controllen = 2 * tswapal(msgp->msg_controllen);
msg.msg_control = alloca(msg.msg_controllen);
+ memset(msg.msg_control, 0, msg.msg_controllen);
+
msg.msg_flags = tswap32(msgp->msg_flags);
count = tswapal(msgp->msg_iovlen);