From 5bfb8d2585b5c3cc52195066a7794c5c0e6dbbb3 Mon Sep 17 00:00:00 2001 From: gkehren Date: Thu, 23 Jul 2026 16:40:25 +0200 Subject: [PATCH] core: tolerate kernels without POSIX mqueue support PrivateIPC= sets up a private mqueue mount for the service. When CONFIG_POSIX_MQUEUE is disabled, mounting mqueue fails with ENODEV and prevents the service from starting. Treat ENODEV as an unavailable optional kernel feature while preserving the private IPC namespace. Keep all other mount errors fatal. Add coverage verifying that PrivateIPC= still creates a separate IPC namespace when POSIX message queues are unavailable. Fixes #42582 (cherry picked from commit 9d217e051b842c635d7046cf5a990d529815f6a4) (cherry picked from commit 104bbafc9af6c3497ac16c1e93f90687b72aac78) --- src/core/namespace.c | 2 ++ test/units/TEST-07-PID1.mqueue-ownership.sh | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/core/namespace.c b/src/core/namespace.c index 70f86641dd8..ce737f3f3e4 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -1641,6 +1641,8 @@ static int mount_mqueuefs(const MountEntry *m) { (void) umount_recursive(entry_path, 0); r = mount_nofollow_verbose(LOG_DEBUG, "mqueue", entry_path, "mqueue", m->flags, mount_entry_options(m)); + if (r == -ENODEV) /* POSIX message queues may be disabled in the kernel. */ + return 0; if (r < 0) return r; diff --git a/test/units/TEST-07-PID1.mqueue-ownership.sh b/test/units/TEST-07-PID1.mqueue-ownership.sh index 3f3f83f5821..bdb3dfd74f8 100755 --- a/test/units/TEST-07-PID1.mqueue-ownership.sh +++ b/test/units/TEST-07-PID1.mqueue-ownership.sh @@ -3,6 +3,17 @@ set -eux set -o pipefail +# Verify PrivateIPC= works and creates a separate IPC namespace even if POSIX +# message queues are not supported. +host_ipcns=$(readlink /proc/self/ns/ipc) +private_ipcns=$(systemd-run --quiet --wait --pipe -p PrivateIPC=yes readlink /proc/self/ns/ipc) +[[ "$private_ipcns" != "$host_ipcns" ]] + +if [[ ! -d /proc/sys/fs/mqueue ]]; then + echo "POSIX message queues are not supported, skipping ownership checks" + exit 0 +fi + # Verify ownership attributes are applied to message queues # Select arbitrary non-default attributes to apply to the queue.