[CRIU] [PATCH 2/3] util: zero msghdr structures

Andrei Vagin avagin at openvz.org
Wed Jan 25 13:06:09 PST 2017


From: Andrei Vagin <avagin at virtuozzo.com>

musl-libc fixed inconsistency between posix and kernl msghdr structures
by adding pad-s.

It initializes all pad-s before calling recvmsg and sendmsg syscalls.
CRIU calls raw system calls from pie code, so we need to intialize pads too.

In addition, we don't initialize msg_flags and iov_len.

https://github.com/xemul/criu/issues/276
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 include/common/scm-code.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/common/scm-code.c b/include/common/scm-code.c
index 504c972..9808fed 100644
--- a/include/common/scm-code.c
+++ b/include/common/scm-code.c
@@ -54,7 +54,8 @@ static int *scm_fdset_init(struct scm_fdset *fdset, struct sockaddr_un *saddr,
 int send_fds(int sock, struct sockaddr_un *saddr, int len,
 		int *fds, int nr_fds, void *data, unsigned ch_size)
 {
-	struct scm_fdset fdset;
+	/* In musl_libc the msghdr structure has pads which has to be zeroed */
+	struct scm_fdset fdset = {};
 	int *cmsg_data;
 	int i, min_fd, ret;
 
@@ -77,7 +78,8 @@ int send_fds(int sock, struct sockaddr_un *saddr, int len,
 
 int recv_fds(int sock, int *fds, int nr_fds, void *data, unsigned ch_size)
 {
-	struct scm_fdset fdset;
+	/* In musl_libc the msghdr structure has pads which has to be zeroed */
+	struct scm_fdset fdset = {};
 	struct cmsghdr *cmsg;
 	int *cmsg_data;
 	int ret;
-- 
2.7.4



More information about the CRIU mailing list