diff options
| -rw-r--r-- | meta/recipes-core/systemd/systemd/27253.patch | 313 | ||||
| -rw-r--r-- | meta/recipes-core/systemd/systemd/27254.patch | 345 | ||||
| -rw-r--r-- | meta/recipes-core/systemd/systemd_253.3.bb | 2 |
3 files changed, 660 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/27253.patch b/meta/recipes-core/systemd/systemd/27253.patch new file mode 100644 index 0000000000..6c556fe80f --- /dev/null +++ b/meta/recipes-core/systemd/systemd/27253.patch | |||
| @@ -0,0 +1,313 @@ | |||
| 1 | From 924937cbc0bf692bc6e5b3a0bd3c18347d9521e9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Yu Watanabe <watanabe.yu+github@gmail.com> | ||
| 3 | Date: Thu, 13 Apr 2023 16:40:36 +0900 | ||
| 4 | Subject: [PATCH 1/7] timesync: drop unnecessary initialization | ||
| 5 | |||
| 6 | Upstream-Status: Submitted [https://github.com/systemd/systemd/pull/27253] | ||
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 8 | --- | ||
| 9 | src/timesync/timesyncd-manager.c | 2 +- | ||
| 10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 11 | |||
| 12 | --- a/src/timesync/timesyncd-manager.c | ||
| 13 | +++ b/src/timesync/timesyncd-manager.c | ||
| 14 | @@ -410,7 +410,7 @@ static int manager_receive_response(sd_e | ||
| 15 | .msg_name = &server_addr, | ||
| 16 | .msg_namelen = sizeof(server_addr), | ||
| 17 | }; | ||
| 18 | - struct timespec *recv_time = NULL; | ||
| 19 | + struct timespec *recv_time; | ||
| 20 | triple_timestamp dts; | ||
| 21 | ssize_t len; | ||
| 22 | double origin, receive, trans, dest, delay, offset, root_distance; | ||
| 23 | @@ -445,7 +445,7 @@ static int manager_receive_response(sd_e | ||
| 24 | return 0; | ||
| 25 | } | ||
| 26 | |||
| 27 | - recv_time = CMSG_FIND_DATA(&msghdr, SOL_SOCKET, SCM_TIMESTAMPNS, struct timespec); | ||
| 28 | + recv_time = CMSG_FIND_AND_COPY_DATA(&msghdr, SOL_SOCKET, SCM_TIMESTAMPNS, struct timespec); | ||
| 29 | if (!recv_time) | ||
| 30 | return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Packet timestamp missing."); | ||
| 31 | |||
| 32 | --- a/src/basic/socket-util.h | ||
| 33 | +++ b/src/basic/socket-util.h | ||
| 34 | @@ -183,17 +183,22 @@ int flush_accept(int fd); | ||
| 35 | * riscv32. */ | ||
| 36 | #define CMSG_TYPED_DATA(cmsg, type) \ | ||
| 37 | ({ \ | ||
| 38 | - struct cmsghdr *_cmsg = cmsg; \ | ||
| 39 | - assert_cc(__alignof__(type) <= __alignof__(struct cmsghdr)); \ | ||
| 40 | + struct cmsghdr *_cmsg = (cmsg); \ | ||
| 41 | + assert_cc(alignof(type) <= alignof(struct cmsghdr)); \ | ||
| 42 | _cmsg ? CAST_ALIGN_PTR(type, CMSG_DATA(_cmsg)) : (type*) NULL; \ | ||
| 43 | }) | ||
| 44 | |||
| 45 | struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t length); | ||
| 46 | +void* cmsg_find_and_copy_data(struct msghdr *mh, int level, int type, void *buf, size_t buf_len); | ||
| 47 | |||
| 48 | /* Type-safe, dereferencing version of cmsg_find() */ | ||
| 49 | #define CMSG_FIND_DATA(mh, level, type, ctype) \ | ||
| 50 | CMSG_TYPED_DATA(cmsg_find(mh, level, type, CMSG_LEN(sizeof(ctype))), ctype) | ||
| 51 | |||
| 52 | +/* Type-safe version of cmsg_find_and_copy_data() */ | ||
| 53 | +#define CMSG_FIND_AND_COPY_DATA(mh, level, type, ctype) \ | ||
| 54 | + (ctype*) cmsg_find_and_copy_data(mh, level, type, &(ctype){}, sizeof(ctype)) | ||
| 55 | + | ||
| 56 | /* Resolves to a type that can carry cmsghdr structures. Make sure things are properly aligned, i.e. the type | ||
| 57 | * itself is placed properly in memory and the size is also aligned to what's appropriate for "cmsghdr" | ||
| 58 | * structures. */ | ||
| 59 | --- a/src/boot/efi/pe.c | ||
| 60 | +++ b/src/boot/efi/pe.c | ||
| 61 | @@ -197,7 +197,7 @@ static uint32_t get_compatibility_entry_ | ||
| 62 | uint32_t entry_point; | ||
| 63 | } _packed_ LinuxPeCompat1; | ||
| 64 | |||
| 65 | - while (size >= sizeof(LinuxPeCompat1) && addr % __alignof__(LinuxPeCompat1) == 0) { | ||
| 66 | + while (size >= sizeof(LinuxPeCompat1) && addr % alignof(LinuxPeCompat1) == 0) { | ||
| 67 | LinuxPeCompat1 *compat = (LinuxPeCompat1 *) ((uint8_t *) dos + addr); | ||
| 68 | |||
| 69 | if (compat->type == 0 || compat->size == 0 || compat->size > size) | ||
| 70 | --- a/src/fundamental/macro-fundamental.h | ||
| 71 | +++ b/src/fundamental/macro-fundamental.h | ||
| 72 | @@ -6,12 +6,13 @@ | ||
| 73 | #endif | ||
| 74 | |||
| 75 | #include <limits.h> | ||
| 76 | +#include <stdalign.h> | ||
| 77 | #include <stdbool.h> | ||
| 78 | #include <stddef.h> | ||
| 79 | #include <stdint.h> | ||
| 80 | |||
| 81 | #define _align_(x) __attribute__((__aligned__(x))) | ||
| 82 | -#define _alignas_(x) __attribute__((__aligned__(__alignof__(x)))) | ||
| 83 | +#define _alignas_(x) __attribute__((__aligned__(alignof(x)))) | ||
| 84 | #define _alignptr_ __attribute__((__aligned__(sizeof(void *)))) | ||
| 85 | #define _cleanup_(x) __attribute__((__cleanup__(x))) | ||
| 86 | #define _const_ __attribute__((__const__)) | ||
| 87 | @@ -346,9 +347,9 @@ static inline size_t ALIGN_TO(size_t l, | ||
| 88 | #endif | ||
| 89 | |||
| 90 | /* Checks if the specified pointer is aligned as appropriate for the specific type */ | ||
| 91 | -#define IS_ALIGNED16(p) (((uintptr_t) p) % __alignof__(uint16_t) == 0) | ||
| 92 | -#define IS_ALIGNED32(p) (((uintptr_t) p) % __alignof__(uint32_t) == 0) | ||
| 93 | -#define IS_ALIGNED64(p) (((uintptr_t) p) % __alignof__(uint64_t) == 0) | ||
| 94 | +#define IS_ALIGNED16(p) (((uintptr_t) p) % alignof(uint16_t) == 0) | ||
| 95 | +#define IS_ALIGNED32(p) (((uintptr_t) p) % alignof(uint32_t) == 0) | ||
| 96 | +#define IS_ALIGNED64(p) (((uintptr_t) p) % alignof(uint64_t) == 0) | ||
| 97 | |||
| 98 | /* Same as ALIGN_TO but callable in constant contexts. */ | ||
| 99 | #define CONST_ALIGN_TO(l, ali) \ | ||
| 100 | @@ -366,7 +367,7 @@ static inline size_t ALIGN_TO(size_t l, | ||
| 101 | #define CAST_ALIGN_PTR(t, p) \ | ||
| 102 | ({ \ | ||
| 103 | const void *_p = (p); \ | ||
| 104 | - assert(((uintptr_t) _p) % __alignof__(t) == 0); \ | ||
| 105 | + assert(((uintptr_t) _p) % alignof(t) == 0); \ | ||
| 106 | (t *) _p; \ | ||
| 107 | }) | ||
| 108 | |||
| 109 | --- a/src/network/networkd-nexthop.c | ||
| 110 | +++ b/src/network/networkd-nexthop.c | ||
| 111 | @@ -894,7 +894,7 @@ int manager_rtnl_process_nexthop(sd_netl | ||
| 112 | return 0; | ||
| 113 | } | ||
| 114 | |||
| 115 | - assert((uintptr_t) group % __alignof__(struct nexthop_grp) == 0); | ||
| 116 | + assert((uintptr_t) group % alignof(struct nexthop_grp) == 0); | ||
| 117 | |||
| 118 | n_group = raw_group_size / sizeof(struct nexthop_grp); | ||
| 119 | for (size_t i = 0; i < n_group; i++) { | ||
| 120 | --- a/src/test/test-sizeof.c | ||
| 121 | +++ b/src/test/test-sizeof.c | ||
| 122 | @@ -17,16 +17,16 @@ | ||
| 123 | DISABLE_WARNING_TYPE_LIMITS; | ||
| 124 | |||
| 125 | #define info_no_sign(t) \ | ||
| 126 | - printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t), \ | ||
| 127 | + printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t), \ | ||
| 128 | sizeof(t)*CHAR_BIT, \ | ||
| 129 | - __alignof__(t)) | ||
| 130 | + alignof(t)) | ||
| 131 | |||
| 132 | #define info(t) \ | ||
| 133 | - printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \ | ||
| 134 | + printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \ | ||
| 135 | sizeof(t)*CHAR_BIT, \ | ||
| 136 | strstr(STRINGIFY(t), "signed") ? "" : \ | ||
| 137 | (t)-1 < (t)0 ? ", signed" : ", unsigned", \ | ||
| 138 | - __alignof__(t)) | ||
| 139 | + alignof(t)) | ||
| 140 | |||
| 141 | enum Enum { | ||
| 142 | enum_value, | ||
| 143 | @@ -44,7 +44,7 @@ enum BigEnum2 { | ||
| 144 | int main(void) { | ||
| 145 | int (*function_pointer)(void); | ||
| 146 | |||
| 147 | - info_no_sign(function_pointer); | ||
| 148 | + info_no_sign(typeof(function_pointer)); | ||
| 149 | info_no_sign(void*); | ||
| 150 | info(char*); | ||
| 151 | |||
| 152 | --- a/src/basic/socket-util.c | ||
| 153 | +++ b/src/basic/socket-util.c | ||
| 154 | @@ -1171,6 +1171,18 @@ struct cmsghdr* cmsg_find(struct msghdr | ||
| 155 | return NULL; | ||
| 156 | } | ||
| 157 | |||
| 158 | +void* cmsg_find_and_copy_data(struct msghdr *mh, int level, int type, void *buf, size_t buf_len) { | ||
| 159 | + struct cmsghdr *cmsg; | ||
| 160 | + | ||
| 161 | + assert(mh); | ||
| 162 | + | ||
| 163 | + cmsg = cmsg_find(mh, level, type, buf_len == SIZE_MAX ? (socklen_t) -1 : CMSG_LEN(buf_len)); | ||
| 164 | + if (!cmsg) | ||
| 165 | + return NULL; | ||
| 166 | + | ||
| 167 | + return memcpy_safe(buf, CMSG_DATA(cmsg), buf_len == SIZE_MAX ? cmsg->cmsg_len : buf_len); | ||
| 168 | +} | ||
| 169 | + | ||
| 170 | int socket_ioctl_fd(void) { | ||
| 171 | int fd; | ||
| 172 | |||
| 173 | --- a/src/journal/journald-server.c | ||
| 174 | +++ b/src/journal/journald-server.c | ||
| 175 | @@ -1385,7 +1385,7 @@ int server_process_datagram( | ||
| 176 | size_t label_len = 0, m; | ||
| 177 | Server *s = ASSERT_PTR(userdata); | ||
| 178 | struct ucred *ucred = NULL; | ||
| 179 | - struct timeval *tv = NULL; | ||
| 180 | + struct timeval tv_buf, *tv = NULL; | ||
| 181 | struct cmsghdr *cmsg; | ||
| 182 | char *label = NULL; | ||
| 183 | struct iovec iovec; | ||
| 184 | @@ -1461,10 +1461,10 @@ int server_process_datagram( | ||
| 185 | label = CMSG_TYPED_DATA(cmsg, char); | ||
| 186 | label_len = cmsg->cmsg_len - CMSG_LEN(0); | ||
| 187 | } else if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 188 | - cmsg->cmsg_type == SO_TIMESTAMP && | ||
| 189 | + cmsg->cmsg_type == SCM_TIMESTAMP && | ||
| 190 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) { | ||
| 191 | assert(!tv); | ||
| 192 | - tv = CMSG_TYPED_DATA(cmsg, struct timeval); | ||
| 193 | + tv = memcpy(&tv_buf, CMSG_DATA(cmsg), sizeof(struct timeval)); | ||
| 194 | } else if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 195 | cmsg->cmsg_type == SCM_RIGHTS) { | ||
| 196 | assert(!fds); | ||
| 197 | --- a/src/libsystemd-network/icmp6-util.c | ||
| 198 | +++ b/src/libsystemd-network/icmp6-util.c | ||
| 199 | @@ -199,9 +199,11 @@ int icmp6_receive(int fd, void *buffer, | ||
| 200 | } | ||
| 201 | |||
| 202 | if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 203 | - cmsg->cmsg_type == SO_TIMESTAMP && | ||
| 204 | - cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) | ||
| 205 | - triple_timestamp_from_realtime(&t, timeval_load(CMSG_TYPED_DATA(cmsg, struct timeval))); | ||
| 206 | + cmsg->cmsg_type == SCM_TIMESTAMP && | ||
| 207 | + cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) { | ||
| 208 | + struct timeval *tv = memcpy(&(struct timeval) {}, CMSG_DATA(cmsg), sizeof(struct timeval)); | ||
| 209 | + triple_timestamp_from_realtime(&t, timeval_load(tv)); | ||
| 210 | + } | ||
| 211 | } | ||
| 212 | |||
| 213 | if (!triple_timestamp_is_set(&t)) | ||
| 214 | --- a/src/libsystemd-network/sd-dhcp6-client.c | ||
| 215 | +++ b/src/libsystemd-network/sd-dhcp6-client.c | ||
| 216 | @@ -1276,7 +1276,6 @@ static int client_receive_message( | ||
| 217 | .msg_control = &control, | ||
| 218 | .msg_controllen = sizeof(control), | ||
| 219 | }; | ||
| 220 | - struct cmsghdr *cmsg; | ||
| 221 | triple_timestamp t = {}; | ||
| 222 | _cleanup_free_ DHCP6Message *message = NULL; | ||
| 223 | struct in6_addr *server_address = NULL; | ||
| 224 | @@ -1320,12 +1319,9 @@ static int client_receive_message( | ||
| 225 | server_address = &sa.in6.sin6_addr; | ||
| 226 | } | ||
| 227 | |||
| 228 | - CMSG_FOREACH(cmsg, &msg) { | ||
| 229 | - if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 230 | - cmsg->cmsg_type == SO_TIMESTAMP && | ||
| 231 | - cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) | ||
| 232 | - triple_timestamp_from_realtime(&t, timeval_load(CMSG_TYPED_DATA(cmsg, struct timeval))); | ||
| 233 | - } | ||
| 234 | + struct timeval *tv = CMSG_FIND_AND_COPY_DATA(&msg, SOL_SOCKET, SCM_TIMESTAMP, struct timeval); | ||
| 235 | + if (tv) | ||
| 236 | + triple_timestamp_from_realtime(&t, timeval_load(tv)); | ||
| 237 | |||
| 238 | if (client->transaction_id != (message->transaction_id & htobe32(0x00ffffff))) | ||
| 239 | return 0; | ||
| 240 | --- a/src/libsystemd-network/sd-dhcp-server.c | ||
| 241 | +++ b/src/libsystemd-network/sd-dhcp-server.c | ||
| 242 | @@ -407,7 +407,7 @@ static int dhcp_server_send_udp(sd_dhcp_ | ||
| 243 | rather than binding the socket. This will be mostly useful | ||
| 244 | when we gain support for arbitrary number of server addresses | ||
| 245 | */ | ||
| 246 | - pktinfo = (struct in_pktinfo*) CMSG_DATA(cmsg); | ||
| 247 | + pktinfo = CMSG_TYPED_DATA(cmsg, struct in_pktinfo); | ||
| 248 | assert(pktinfo); | ||
| 249 | |||
| 250 | pktinfo->ipi_ifindex = server->ifindex; | ||
| 251 | @@ -1270,7 +1270,6 @@ static int server_receive_message(sd_eve | ||
| 252 | .msg_control = &control, | ||
| 253 | .msg_controllen = sizeof(control), | ||
| 254 | }; | ||
| 255 | - struct cmsghdr *cmsg; | ||
| 256 | ssize_t datagram_size, len; | ||
| 257 | int r; | ||
| 258 | |||
| 259 | @@ -1306,19 +1305,10 @@ static int server_receive_message(sd_eve | ||
| 260 | if ((size_t) len < sizeof(DHCPMessage)) | ||
| 261 | return 0; | ||
| 262 | |||
| 263 | - CMSG_FOREACH(cmsg, &msg) | ||
| 264 | - if (cmsg->cmsg_level == IPPROTO_IP && | ||
| 265 | - cmsg->cmsg_type == IP_PKTINFO && | ||
| 266 | - cmsg->cmsg_len == CMSG_LEN(sizeof(struct in_pktinfo))) { | ||
| 267 | - struct in_pktinfo *info = CMSG_TYPED_DATA(cmsg, struct in_pktinfo); | ||
| 268 | - | ||
| 269 | - /* TODO figure out if this can be done as a filter on | ||
| 270 | - * the socket, like for IPv6 */ | ||
| 271 | - if (server->ifindex != info->ipi_ifindex) | ||
| 272 | - return 0; | ||
| 273 | - | ||
| 274 | - break; | ||
| 275 | - } | ||
| 276 | + /* TODO figure out if this can be done as a filter on the socket, like for IPv6 */ | ||
| 277 | + struct in_pktinfo *info = CMSG_FIND_DATA(&msg, IPPROTO_IP, IP_PKTINFO, struct in_pktinfo); | ||
| 278 | + if (info && info->ipi_ifindex != server->ifindex) | ||
| 279 | + return 0; | ||
| 280 | |||
| 281 | if (sd_dhcp_server_is_in_relay_mode(server)) { | ||
| 282 | r = dhcp_server_relay_message(server, message, len - sizeof(DHCPMessage), buflen); | ||
| 283 | --- a/src/libsystemd/sd-daemon/sd-daemon.c | ||
| 284 | +++ b/src/libsystemd/sd-daemon/sd-daemon.c | ||
| 285 | @@ -567,7 +567,7 @@ _public_ int sd_pid_notify_with_fds( | ||
| 286 | cmsg->cmsg_type = SCM_CREDENTIALS; | ||
| 287 | cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred)); | ||
| 288 | |||
| 289 | - ucred = (struct ucred*) CMSG_DATA(cmsg); | ||
| 290 | + ucred = CMSG_TYPED_DATA(cmsg, struct ucred); | ||
| 291 | ucred->pid = pid != 0 ? pid : getpid_cached(); | ||
| 292 | ucred->uid = getuid(); | ||
| 293 | ucred->gid = getgid(); | ||
| 294 | --- a/src/resolve/resolved-manager.c | ||
| 295 | +++ b/src/resolve/resolved-manager.c | ||
| 296 | @@ -984,7 +984,7 @@ static int manager_ipv4_send( | ||
| 297 | cmsg->cmsg_level = IPPROTO_IP; | ||
| 298 | cmsg->cmsg_type = IP_PKTINFO; | ||
| 299 | |||
| 300 | - pi = (struct in_pktinfo*) CMSG_DATA(cmsg); | ||
| 301 | + pi = CMSG_TYPED_DATA(cmsg, struct in_pktinfo); | ||
| 302 | pi->ipi_ifindex = ifindex; | ||
| 303 | |||
| 304 | if (source) | ||
| 305 | @@ -1040,7 +1040,7 @@ static int manager_ipv6_send( | ||
| 306 | cmsg->cmsg_level = IPPROTO_IPV6; | ||
| 307 | cmsg->cmsg_type = IPV6_PKTINFO; | ||
| 308 | |||
| 309 | - pi = (struct in6_pktinfo*) CMSG_DATA(cmsg); | ||
| 310 | + pi = CMSG_TYPED_DATA(cmsg, struct in6_pktinfo); | ||
| 311 | pi->ipi6_ifindex = ifindex; | ||
| 312 | |||
| 313 | if (source) | ||
diff --git a/meta/recipes-core/systemd/systemd/27254.patch b/meta/recipes-core/systemd/systemd/27254.patch new file mode 100644 index 0000000000..3928088dc6 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/27254.patch | |||
| @@ -0,0 +1,345 @@ | |||
| 1 | From 79dec6f5cc0b72d43dfb0469fa68b5cd023fbaf9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Lennart Poettering <lennart@poettering.net> | ||
| 3 | Date: Thu, 13 Apr 2023 10:21:31 +0200 | ||
| 4 | Subject: [PATCH 1/3] socket-util: tighten aignment check for CMSG_TYPED_DATA() | ||
| 5 | |||
| 6 | Apparently CMSG_DATA() alignment is very much undefined. Which is quite | ||
| 7 | an ABI fuck-up, but we need to deal with this. CMSG_TYPED_DATA() already | ||
| 8 | checks alignment of the specified pointer. Let's also check matching | ||
| 9 | alignment of the underlying structures, which we already can do at | ||
| 10 | compile-time. | ||
| 11 | |||
| 12 | See: #27241 | ||
| 13 | |||
| 14 | (This does not fix #27241, but should catch such errors already at | ||
| 15 | compile-time instead of runtime) | ||
| 16 | |||
| 17 | Upstream-Status: Backport [https://github.com/systemd/systemd/pull/27254] | ||
| 18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 19 | --- | ||
| 20 | src/basic/socket-util.h | 7 +++++++ | ||
| 21 | 1 file changed, 7 insertions(+) | ||
| 22 | |||
| 23 | --- a/src/basic/socket-util.h | ||
| 24 | +++ b/src/basic/socket-util.h | ||
| 25 | @@ -175,9 +175,16 @@ int flush_accept(int fd); | ||
| 26 | #define CMSG_FOREACH(cmsg, mh) \ | ||
| 27 | for ((cmsg) = CMSG_FIRSTHDR(mh); (cmsg); (cmsg) = CMSG_NXTHDR((mh), (cmsg))) | ||
| 28 | |||
| 29 | +/* Returns the cmsghdr's data pointer, but safely cast to the specified type. Does two alignment checks: one | ||
| 30 | + * at compile time, that the requested type has a smaller or same alignment as 'struct cmsghdr', and one | ||
| 31 | + * during runtime, that the actual pointer matches the alignment too. This is supposed to catch cases such as | ||
| 32 | + * 'struct timeval' is embedded into 'struct cmsghdr' on architectures where the alignment of the former is 8 | ||
| 33 | + * bytes (because of a 64bit time_t), but of the latter is 4 bytes (because size_t is 32bit), such as | ||
| 34 | + * riscv32. */ | ||
| 35 | #define CMSG_TYPED_DATA(cmsg, type) \ | ||
| 36 | ({ \ | ||
| 37 | struct cmsghdr *_cmsg = cmsg; \ | ||
| 38 | + assert_cc(__alignof__(type) <= __alignof__(struct cmsghdr)); \ | ||
| 39 | _cmsg ? CAST_ALIGN_PTR(type, CMSG_DATA(_cmsg)) : (type*) NULL; \ | ||
| 40 | }) | ||
| 41 | |||
| 42 | --- a/src/basic/socket-util.c | ||
| 43 | +++ b/src/basic/socket-util.c | ||
| 44 | @@ -1047,7 +1047,7 @@ ssize_t receive_one_fd_iov( | ||
| 45 | } | ||
| 46 | |||
| 47 | if (found) | ||
| 48 | - *ret_fd = *(int*) CMSG_DATA(found); | ||
| 49 | + *ret_fd = *CMSG_TYPED_DATA(found, int); | ||
| 50 | else | ||
| 51 | *ret_fd = -EBADF; | ||
| 52 | |||
| 53 | --- a/src/core/manager.c | ||
| 54 | +++ b/src/core/manager.c | ||
| 55 | @@ -2503,7 +2503,7 @@ static int manager_dispatch_notify_fd(sd | ||
| 56 | if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { | ||
| 57 | |||
| 58 | assert(!fd_array); | ||
| 59 | - fd_array = (int*) CMSG_DATA(cmsg); | ||
| 60 | + fd_array = CMSG_TYPED_DATA(cmsg, int); | ||
| 61 | n_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int); | ||
| 62 | |||
| 63 | } else if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 64 | @@ -2511,7 +2511,7 @@ static int manager_dispatch_notify_fd(sd | ||
| 65 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) { | ||
| 66 | |||
| 67 | assert(!ucred); | ||
| 68 | - ucred = (struct ucred*) CMSG_DATA(cmsg); | ||
| 69 | + ucred = CMSG_TYPED_DATA(cmsg, struct ucred); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | --- a/src/coredump/coredump.c | ||
| 74 | +++ b/src/coredump/coredump.c | ||
| 75 | @@ -1163,7 +1163,7 @@ static int process_socket(int fd) { | ||
| 76 | } | ||
| 77 | |||
| 78 | assert(input_fd < 0); | ||
| 79 | - input_fd = *(int*) CMSG_DATA(found); | ||
| 80 | + input_fd = *CMSG_TYPED_DATA(found, int); | ||
| 81 | break; | ||
| 82 | } else | ||
| 83 | cmsg_close_all(&mh); | ||
| 84 | --- a/src/home/homed-manager.c | ||
| 85 | +++ b/src/home/homed-manager.c | ||
| 86 | @@ -1086,7 +1086,7 @@ static ssize_t read_datagram( | ||
| 87 | cmsg->cmsg_type == SCM_CREDENTIALS && | ||
| 88 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) { | ||
| 89 | assert(!sender); | ||
| 90 | - sender = (struct ucred*) CMSG_DATA(cmsg); | ||
| 91 | + sender = CMSG_TYPED_DATA(cmsg, struct ucred); | ||
| 92 | } | ||
| 93 | |||
| 94 | if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 95 | @@ -1098,7 +1098,7 @@ static ssize_t read_datagram( | ||
| 96 | } | ||
| 97 | |||
| 98 | assert(passed_fd < 0); | ||
| 99 | - passed_fd = *(int*) CMSG_DATA(cmsg); | ||
| 100 | + passed_fd = *CMSG_TYPED_DATA(cmsg, int); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | --- a/src/journal/journald-server.c | ||
| 105 | +++ b/src/journal/journald-server.c | ||
| 106 | @@ -1454,21 +1454,21 @@ int server_process_datagram( | ||
| 107 | cmsg->cmsg_type == SCM_CREDENTIALS && | ||
| 108 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct ucred))) { | ||
| 109 | assert(!ucred); | ||
| 110 | - ucred = (struct ucred*) CMSG_DATA(cmsg); | ||
| 111 | + ucred = CMSG_TYPED_DATA(cmsg, struct ucred); | ||
| 112 | } else if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 113 | cmsg->cmsg_type == SCM_SECURITY) { | ||
| 114 | assert(!label); | ||
| 115 | - label = (char*) CMSG_DATA(cmsg); | ||
| 116 | + label = CMSG_TYPED_DATA(cmsg, char); | ||
| 117 | label_len = cmsg->cmsg_len - CMSG_LEN(0); | ||
| 118 | } else if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 119 | cmsg->cmsg_type == SO_TIMESTAMP && | ||
| 120 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) { | ||
| 121 | assert(!tv); | ||
| 122 | - tv = (struct timeval*) CMSG_DATA(cmsg); | ||
| 123 | + tv = CMSG_TYPED_DATA(cmsg, struct timeval); | ||
| 124 | } else if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 125 | cmsg->cmsg_type == SCM_RIGHTS) { | ||
| 126 | assert(!fds); | ||
| 127 | - fds = (int*) CMSG_DATA(cmsg); | ||
| 128 | + fds = CMSG_TYPED_DATA(cmsg, int); | ||
| 129 | n_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int); | ||
| 130 | } | ||
| 131 | |||
| 132 | --- a/src/libsystemd-network/icmp6-util.c | ||
| 133 | +++ b/src/libsystemd-network/icmp6-util.c | ||
| 134 | @@ -192,7 +192,7 @@ int icmp6_receive(int fd, void *buffer, | ||
| 135 | if (cmsg->cmsg_level == SOL_IPV6 && | ||
| 136 | cmsg->cmsg_type == IPV6_HOPLIMIT && | ||
| 137 | cmsg->cmsg_len == CMSG_LEN(sizeof(int))) { | ||
| 138 | - int hops = *(int*) CMSG_DATA(cmsg); | ||
| 139 | + int hops = *CMSG_TYPED_DATA(cmsg, int); | ||
| 140 | |||
| 141 | if (hops != 255) | ||
| 142 | return -EMULTIHOP; | ||
| 143 | @@ -201,7 +201,7 @@ int icmp6_receive(int fd, void *buffer, | ||
| 144 | if (cmsg->cmsg_level == SOL_SOCKET && | ||
| 145 | cmsg->cmsg_type == SO_TIMESTAMP && | ||
| 146 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct timeval))) | ||
| 147 | - triple_timestamp_from_realtime(&t, timeval_load((struct timeval*) CMSG_DATA(cmsg))); | ||
| 148 | + triple_timestamp_from_realtime(&t, timeval_load(CMSG_TYPED_DATA(cmsg, struct timeval))); | ||
| 149 | } | ||
| 150 | |||
| 151 | if (!triple_timestamp_is_set(&t)) | ||
| 152 | --- a/src/libsystemd-network/sd-dhcp-client.c | ||
| 153 | +++ b/src/libsystemd-network/sd-dhcp-client.c | ||
| 154 | @@ -1981,7 +1981,7 @@ static int client_receive_message_raw( | ||
| 155 | |||
| 156 | cmsg = cmsg_find(&msg, SOL_PACKET, PACKET_AUXDATA, CMSG_LEN(sizeof(struct tpacket_auxdata))); | ||
| 157 | if (cmsg) { | ||
| 158 | - struct tpacket_auxdata *aux = (struct tpacket_auxdata*) CMSG_DATA(cmsg); | ||
| 159 | + struct tpacket_auxdata *aux = CMSG_TYPED_DATA(cmsg, struct tpacket_auxdata); | ||
| 160 | checksum = !(aux->tp_status & TP_STATUS_CSUMNOTREADY); | ||
| 161 | } | ||
| 162 | |||
| 163 | --- a/src/libsystemd-network/sd-dhcp-server.c | ||
| 164 | +++ b/src/libsystemd-network/sd-dhcp-server.c | ||
| 165 | @@ -1310,7 +1310,7 @@ static int server_receive_message(sd_eve | ||
| 166 | if (cmsg->cmsg_level == IPPROTO_IP && | ||
| 167 | cmsg->cmsg_type == IP_PKTINFO && | ||
| 168 | cmsg->cmsg_len == CMSG_LEN(sizeof(struct in_pktinfo))) { | ||
| 169 | - struct in_pktinfo *info = (struct in_pktinfo*)CMSG_DATA(cmsg); | ||
| 170 | + struct in_pktinfo *info = CMSG_TYPED_DATA(cmsg, struct in_pktinfo); | ||
| 171 | |||
| 172 | /* TODO figure out if this can be done as a filter on | ||
| 173 | * the socket, like for IPv6 */ | ||
| 174 | --- a/src/libsystemd/sd-bus/bus-socket.c | ||
| 175 | +++ b/src/libsystemd/sd-bus/bus-socket.c | ||
| 176 | @@ -604,7 +604,7 @@ static int bus_socket_read_auth(sd_bus * | ||
| 177 | * protocol? Somebody is playing games with | ||
| 178 | * us. Close them all, and fail */ | ||
| 179 | j = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int); | ||
| 180 | - close_many((int*) CMSG_DATA(cmsg), j); | ||
| 181 | + close_many(CMSG_TYPED_DATA(cmsg, int), j); | ||
| 182 | return -EIO; | ||
| 183 | } else | ||
| 184 | log_debug("Got unexpected auxiliary data with level=%d and type=%d", | ||
| 185 | @@ -1270,18 +1270,18 @@ int bus_socket_read_message(sd_bus *bus) | ||
| 186 | * isn't actually enabled? Close them, | ||
| 187 | * and fail */ | ||
| 188 | |||
| 189 | - close_many((int*) CMSG_DATA(cmsg), n); | ||
| 190 | + close_many(CMSG_TYPED_DATA(cmsg, int), n); | ||
| 191 | return -EIO; | ||
| 192 | } | ||
| 193 | |||
| 194 | f = reallocarray(bus->fds, bus->n_fds + n, sizeof(int)); | ||
| 195 | if (!f) { | ||
| 196 | - close_many((int*) CMSG_DATA(cmsg), n); | ||
| 197 | + close_many(CMSG_TYPED_DATA(cmsg, int), n); | ||
| 198 | return -ENOMEM; | ||
| 199 | } | ||
| 200 | |||
| 201 | for (i = 0; i < n; i++) | ||
| 202 | - f[bus->n_fds++] = fd_move_above_stdio(((int*) CMSG_DATA(cmsg))[i]); | ||
| 203 | + f[bus->n_fds++] = fd_move_above_stdio(CMSG_TYPED_DATA(cmsg, int)[i]); | ||
| 204 | bus->fds = f; | ||
| 205 | } else | ||
| 206 | log_debug("Got unexpected auxiliary data with level=%d and type=%d", | ||
| 207 | --- a/src/resolve/resolved-dns-stream.c | ||
| 208 | +++ b/src/resolve/resolved-dns-stream.c | ||
| 209 | @@ -147,7 +147,7 @@ static int dns_stream_identify(DnsStream | ||
| 210 | switch (cmsg->cmsg_type) { | ||
| 211 | |||
| 212 | case IPV6_PKTINFO: { | ||
| 213 | - struct in6_pktinfo *i = (struct in6_pktinfo*) CMSG_DATA(cmsg); | ||
| 214 | + struct in6_pktinfo *i = CMSG_TYPED_DATA(cmsg, struct in6_pktinfo); | ||
| 215 | |||
| 216 | if (s->ifindex <= 0) | ||
| 217 | s->ifindex = i->ipi6_ifindex; | ||
| 218 | @@ -155,7 +155,7 @@ static int dns_stream_identify(DnsStream | ||
| 219 | } | ||
| 220 | |||
| 221 | case IPV6_HOPLIMIT: | ||
| 222 | - s->ttl = *(int *) CMSG_DATA(cmsg); | ||
| 223 | + s->ttl = *CMSG_TYPED_DATA(cmsg, int); | ||
| 224 | break; | ||
| 225 | } | ||
| 226 | |||
| 227 | @@ -165,7 +165,7 @@ static int dns_stream_identify(DnsStream | ||
| 228 | switch (cmsg->cmsg_type) { | ||
| 229 | |||
| 230 | case IP_PKTINFO: { | ||
| 231 | - struct in_pktinfo *i = (struct in_pktinfo*) CMSG_DATA(cmsg); | ||
| 232 | + struct in_pktinfo *i = CMSG_TYPED_DATA(cmsg, struct in_pktinfo); | ||
| 233 | |||
| 234 | if (s->ifindex <= 0) | ||
| 235 | s->ifindex = i->ipi_ifindex; | ||
| 236 | @@ -173,7 +173,7 @@ static int dns_stream_identify(DnsStream | ||
| 237 | } | ||
| 238 | |||
| 239 | case IP_TTL: | ||
| 240 | - s->ttl = *(int *) CMSG_DATA(cmsg); | ||
| 241 | + s->ttl = *CMSG_TYPED_DATA(cmsg, int); | ||
| 242 | break; | ||
| 243 | } | ||
| 244 | } | ||
| 245 | --- a/src/resolve/resolved-manager.c | ||
| 246 | +++ b/src/resolve/resolved-manager.c | ||
| 247 | @@ -801,7 +801,7 @@ int manager_recv(Manager *m, int fd, Dns | ||
| 248 | switch (cmsg->cmsg_type) { | ||
| 249 | |||
| 250 | case IPV6_PKTINFO: { | ||
| 251 | - struct in6_pktinfo *i = (struct in6_pktinfo*) CMSG_DATA(cmsg); | ||
| 252 | + struct in6_pktinfo *i = CMSG_TYPED_DATA(cmsg, struct in6_pktinfo); | ||
| 253 | |||
| 254 | if (p->ifindex <= 0) | ||
| 255 | p->ifindex = i->ipi6_ifindex; | ||
| 256 | @@ -811,11 +811,11 @@ int manager_recv(Manager *m, int fd, Dns | ||
| 257 | } | ||
| 258 | |||
| 259 | case IPV6_HOPLIMIT: | ||
| 260 | - p->ttl = *(int *) CMSG_DATA(cmsg); | ||
| 261 | + p->ttl = *CMSG_TYPED_DATA(cmsg, int); | ||
| 262 | break; | ||
| 263 | |||
| 264 | case IPV6_RECVFRAGSIZE: | ||
| 265 | - p->fragsize = *(int *) CMSG_DATA(cmsg); | ||
| 266 | + p->fragsize = *CMSG_TYPED_DATA(cmsg, int); | ||
| 267 | break; | ||
| 268 | } | ||
| 269 | } else if (cmsg->cmsg_level == IPPROTO_IP) { | ||
| 270 | @@ -824,7 +824,7 @@ int manager_recv(Manager *m, int fd, Dns | ||
| 271 | switch (cmsg->cmsg_type) { | ||
| 272 | |||
| 273 | case IP_PKTINFO: { | ||
| 274 | - struct in_pktinfo *i = (struct in_pktinfo*) CMSG_DATA(cmsg); | ||
| 275 | + struct in_pktinfo *i = CMSG_TYPED_DATA(cmsg, struct in_pktinfo); | ||
| 276 | |||
| 277 | if (p->ifindex <= 0) | ||
| 278 | p->ifindex = i->ipi_ifindex; | ||
| 279 | @@ -834,11 +834,11 @@ int manager_recv(Manager *m, int fd, Dns | ||
| 280 | } | ||
| 281 | |||
| 282 | case IP_TTL: | ||
| 283 | - p->ttl = *(int *) CMSG_DATA(cmsg); | ||
| 284 | + p->ttl = *CMSG_TYPED_DATA(cmsg, int); | ||
| 285 | break; | ||
| 286 | |||
| 287 | case IP_RECVFRAGSIZE: | ||
| 288 | - p->fragsize = *(int *) CMSG_DATA(cmsg); | ||
| 289 | + p->fragsize = *CMSG_TYPED_DATA(cmsg, int); | ||
| 290 | break; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | --- a/src/libsystemd/sd-device/device-monitor.c | ||
| 294 | +++ b/src/libsystemd/sd-device/device-monitor.c | ||
| 295 | @@ -503,7 +503,6 @@ int device_monitor_receive_device(sd_dev | ||
| 296 | .msg_name = &snl, | ||
| 297 | .msg_namelen = sizeof(snl), | ||
| 298 | }; | ||
| 299 | - struct cmsghdr *cmsg; | ||
| 300 | struct ucred *cred; | ||
| 301 | size_t offset; | ||
| 302 | ssize_t n; | ||
| 303 | @@ -559,12 +558,11 @@ int device_monitor_receive_device(sd_dev | ||
| 304 | snl.nl.nl_pid); | ||
| 305 | } | ||
| 306 | |||
| 307 | - cmsg = CMSG_FIRSTHDR(&smsg); | ||
| 308 | - if (!cmsg || cmsg->cmsg_type != SCM_CREDENTIALS) | ||
| 309 | + cred = CMSG_FIND_DATA(&smsg, SOL_SOCKET, SCM_CREDENTIALS, struct ucred); | ||
| 310 | + if (!cred) | ||
| 311 | return log_monitor_errno(m, SYNTHETIC_ERRNO(EAGAIN), | ||
| 312 | "No sender credentials received, ignoring message."); | ||
| 313 | |||
| 314 | - cred = (struct ucred*) CMSG_DATA(cmsg); | ||
| 315 | if (!check_sender_uid(m, cred->uid)) | ||
| 316 | return log_monitor_errno(m, SYNTHETIC_ERRNO(EAGAIN), | ||
| 317 | "Sender uid="UID_FMT", message ignored.", cred->uid); | ||
| 318 | --- a/src/udev/udev-ctrl.c | ||
| 319 | +++ b/src/udev/udev-ctrl.c | ||
| 320 | @@ -161,7 +161,6 @@ static int udev_ctrl_connection_event_ha | ||
| 321 | .msg_control = &control, | ||
| 322 | .msg_controllen = sizeof(control), | ||
| 323 | }; | ||
| 324 | - struct cmsghdr *cmsg; | ||
| 325 | struct ucred *cred; | ||
| 326 | ssize_t size; | ||
| 327 | |||
| 328 | @@ -185,15 +184,12 @@ static int udev_ctrl_connection_event_ha | ||
| 329 | |||
| 330 | cmsg_close_all(&smsg); | ||
| 331 | |||
| 332 | - cmsg = CMSG_FIRSTHDR(&smsg); | ||
| 333 | - | ||
| 334 | - if (!cmsg || cmsg->cmsg_type != SCM_CREDENTIALS) { | ||
| 335 | + cred = CMSG_FIND_DATA(&smsg, SOL_SOCKET, SCM_CREDENTIALS, struct ucred); | ||
| 336 | + if (!cred) { | ||
| 337 | log_error("No sender credentials received, ignoring message"); | ||
| 338 | return 0; | ||
| 339 | } | ||
| 340 | |||
| 341 | - cred = (struct ucred *) CMSG_DATA(cmsg); | ||
| 342 | - | ||
| 343 | if (cred->uid != 0) { | ||
| 344 | log_error("Invalid sender uid "UID_FMT", ignoring message", cred->uid); | ||
| 345 | return 0; | ||
diff --git a/meta/recipes-core/systemd/systemd_253.3.bb b/meta/recipes-core/systemd/systemd_253.3.bb index 9c2b96d3c1..a79d6cb3ca 100644 --- a/meta/recipes-core/systemd/systemd_253.3.bb +++ b/meta/recipes-core/systemd/systemd_253.3.bb | |||
| @@ -25,6 +25,8 @@ SRC_URI += " \ | |||
| 25 | file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ | 25 | file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ |
| 26 | file://0008-implment-systemd-sysv-install-for-OE.patch \ | 26 | file://0008-implment-systemd-sysv-install-for-OE.patch \ |
| 27 | file://0004-Move-sysusers.d-sysctl.d-binfmt.d-modules-load.d-to-.patch \ | 27 | file://0004-Move-sysusers.d-sysctl.d-binfmt.d-modules-load.d-to-.patch \ |
| 28 | file://27254.patch \ | ||
| 29 | file://27253.patch \ | ||
| 28 | " | 30 | " |
| 29 | 31 | ||
| 30 | # patches needed by musl | 32 | # patches needed by musl |
