diff --git a/README b/README index 88a516d632..53fa8c0bf7 100644 --- a/README +++ b/README @@ -42,7 +42,7 @@ REQUIREMENTS: ≥ 4.17 for cgroup-bpf socket address hooks, /sys/power/resume_offset, and FRA_PROTOCOL attribute for fib rules ≥ 4.20 for PSI (used by systemd-oomd) - ≥ 5.0 for SO_BINDTOIFINDEX + ≥ 5.1 for SO_BINDTOIFINDEX ≥ 5.2 for cgroup freezer and new mount API ≥ 5.3 for bounded loops in BPF program, keyring namespacing, and nexthop support diff --git a/src/basic/missing_socket.h b/src/basic/missing_socket.h index 3dbe735f64..874e93f37e 100644 --- a/src/basic/missing_socket.h +++ b/src/basic/missing_socket.h @@ -3,33 +3,29 @@ #include -#ifndef SO_PEERGROUPS -#define SO_PEERGROUPS 59 -#endif - +/* Supported since kernel v6.5 (5e2ff6704a275be009be8979af17c52361b79b89) */ #ifndef SO_PASSPIDFD #define SO_PASSPIDFD 76 #endif +/* Supported since kernel v6.5 (7b26952a91cf65ff1cc867a2382a8964d8c0ee7d) */ #ifndef SO_PEERPIDFD #define SO_PEERPIDFD 77 #endif -#ifndef SO_BINDTOIFINDEX -#define SO_BINDTOIFINDEX 62 -#endif - /* Not exposed yet. Defined in include/linux/socket.h. */ #ifndef SOL_SCTP #define SOL_SCTP 132 #endif -/* since glibc-2.39 */ +/* Supported since kernel v2.6.17 (2c7946a7bf45ae86736ab3b43d0085e43947945c). + * Defined since glibc-2.39 */ #ifndef SCM_SECURITY #define SCM_SECURITY 0x03 #endif -/* since glibc-2.39 */ +/* Supported since kernel v6.5 (5e2ff6704a275be009be8979af17c52361b79b89). + * Defined since glibc-2.39 */ #ifndef SCM_PIDFD #define SCM_PIDFD 0x04 #endif diff --git a/src/core/manager.c b/src/core/manager.c index 110f20455d..06d6f51a13 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1109,10 +1109,10 @@ static int manager_setup_notify(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to enable SO_PASSCRED for notify socket: %m"); + // TODO: enforce SO_PASSPIDFD when our baseline of the kernel version is bumped to >= 6.5. r = setsockopt_int(fd, SOL_SOCKET, SO_PASSPIDFD, true); if (r < 0 && r != -ENOPROTOOPT) log_warning_errno(r, "Failed to enable SO_PASSPIDFD for notify socket, ignoring: %m"); - // TODO: maybe enforce SO_PASSPIDFD? m->notify_fd = TAKE_FD(fd); @@ -5002,8 +5002,8 @@ static int manager_dispatch_pidref_transport_fd(sd_event_source *source, int fd, * - Child PIDFD in SCM_RIGHTS in message body * - Child PID in message IOV * - * SO_PASSPIDFD may not be supported by the kernel so we fall back to using parent PID from ucreds - * and accept some raciness. */ + * SO_PASSPIDFD may not be supported by the kernel (it is supported since v6.5) so we fall back to + * using parent PID from ucreds and accept some raciness. */ n = recvmsg_safe(m->pidref_transport_fds[0], &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC|MSG_TRUNC); if (ERRNO_IS_NEG_TRANSIENT(n)) return 0; /* Spurious wakeup, try again */ diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 5ae1f16391..13a95ef015 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1509,7 +1509,8 @@ int server_process_datagram( * 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. */ + * __convert_scm_timestamps(), which assumes the buffer is initialized. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred)) + CMSG_SPACE_TIMEVAL + CMSG_SPACE(sizeof(int)) + /* fd */ diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c index 75a6489967..b3e3adfee0 100644 --- a/src/libsystemd-network/icmp6-util.c +++ b/src/libsystemd-network/icmp6-util.c @@ -118,7 +118,8 @@ int icmp6_receive( struct in6_addr *ret_sender, triple_timestamp *ret_timestamp) { - /* This needs to be initialized with zero. See #20741. */ + /* This needs to be initialized with zero. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int)) + /* ttl */ CMSG_SPACE_TIMEVAL) control = {}; struct iovec iov = { buffer, size }; diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 9df4a3dd3f..a319024590 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -2056,7 +2056,8 @@ static int client_receive_message_udp( sd_dhcp_client *client = ASSERT_PTR(userdata); _cleanup_free_ DHCPMessage *message = NULL; ssize_t len, buflen; - /* This needs to be initialized with zero. See #20741. */ + /* This needs to be initialized with zero. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE_TIMEVAL) control = {}; struct iovec iov; struct msghdr msg = { @@ -2107,7 +2108,8 @@ static int client_receive_message_raw( sd_dhcp_client *client = ASSERT_PTR(userdata); _cleanup_free_ DHCPPacket *packet = NULL; - /* This needs to be initialized with zero. See #20741. */ + /* This needs to be initialized with zero. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE_TIMEVAL + CMSG_SPACE(sizeof(struct tpacket_auxdata))) control = {}; struct iovec iov = {}; diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 25b4cafaa5..88c51d5458 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -1225,7 +1225,8 @@ static size_t relay_agent_information_length(const char* agent_circuit_id, const static int server_receive_message(sd_event_source *s, int fd, uint32_t revents, void *userdata) { _cleanup_free_ DHCPMessage *message = NULL; - /* This needs to be initialized with zero. See #20741. */ + /* This needs to be initialized with zero. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE_TIMEVAL + CMSG_SPACE(sizeof(struct in_pktinfo))) control = {}; sd_dhcp_server *server = ASSERT_PTR(userdata); diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 3e992d7cad..ce7254581f 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -1289,7 +1289,8 @@ static int client_receive_message( sd_dhcp6_client *client = ASSERT_PTR(userdata); DHCP6_CLIENT_DONT_DESTROY(client); - /* This needs to be initialized with zero. See #20741. */ + /* This needs to be initialized with zero. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE_TIMEVAL) control = {}; struct iovec iov; union sockaddr_union sa = {}; diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 850c3c580e..e7b962bc30 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -397,7 +397,8 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re .iov_base = &ntpmsg, .iov_len = sizeof(ntpmsg), }; - /* This needs to be initialized with zero. See #20741. */ + /* This needs to be initialized with zero. See #20741. + * The issue is fixed on glibc-2.35 (8fba672472ae0055387e9315fc2eddfa6775ca79). */ CMSG_BUFFER_TYPE(CMSG_SPACE_TIMESPEC) control = {}; union sockaddr_union server_addr; struct msghdr msghdr = {