]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal,network,timesync: fix segfault on 32bit timeval/timespec systems
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 15 Sep 2021 14:29:11 +0000 (23:29 +0900)
committerLennart Poettering <lennart@poettering.net>
Thu, 16 Sep 2021 09:47:44 +0000 (11:47 +0200)
Fixes #20741.

src/journal/journald-server.c
src/libsystemd-network/icmp6-util.c
src/timesync/timesyncd-manager.c

index 8c6684b2d35a8ccfac5a9af765997542ffe525cb..c93499bbc619e5ca5036844468bc62da6a4153d8 100644 (file)
@@ -1267,11 +1267,14 @@ int server_process_datagram(
         /* We use NAME_MAX space for the SELinux label here. The kernel currently enforces no limit, but
          * according to suggestions from the SELinux people this will change and it will probably be
          * identical to NAME_MAX. For now we use that, but this should be updated one day when the final
-         * limit is known. */
+         * limit is known.
+         *
+         * Here, we need to explicitly initialize the buffer with zero, as glibc has a bug in
+         * __convert_scm_timestamps(), which assumes the buffer is initialized. See #20741. */
         CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred)) +
                          CMSG_SPACE_TIMEVAL +
                          CMSG_SPACE(sizeof(int)) + /* fd */
-                         CMSG_SPACE(NAME_MAX) /* selinux label */) control;
+                         CMSG_SPACE(NAME_MAX) /* selinux label */) control = {};
 
         union sockaddr_union sa = {};
 
index 823be0f2752b31cca47cfc457e1048836a7bf697..3832bbd920ce1fef12b174584f20c66b3f91d78a 100644 (file)
@@ -148,8 +148,9 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
 int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *ret_dst,
                   triple_timestamp *ret_timestamp) {
 
+        /* This needs to be initialized with zero. See #20741. */
         CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int)) + /* ttl */
-                         CMSG_SPACE_TIMEVAL) control;
+                         CMSG_SPACE_TIMEVAL) control = {};
         struct iovec iov = {};
         union sockaddr_union sa = {};
         struct msghdr msg = {
index d7060aaa45c5c98a328a352d44bfd614465d954d..f21c5c316ba178a0696334d737d6c14da0905e29 100644 (file)
@@ -416,7 +416,8 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
                 .iov_base = &ntpmsg,
                 .iov_len = sizeof(ntpmsg),
         };
-        CMSG_BUFFER_TYPE(CMSG_SPACE_TIMESPEC) control;
+        /* This needs to be initialized with zero. See #20741. */
+        CMSG_BUFFER_TYPE(CMSG_SPACE_TIMESPEC) control = {};
         union sockaddr_union server_addr;
         struct msghdr msghdr = {
                 .msg_iov = &iov,