]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
binfmt-util: handle ELOOP/EACCES from automount in read-only bind mounts
authorSamuel Dainard <sdainard@amazon.com>
Tue, 28 Apr 2026 15:57:26 +0000 (15:57 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 29 Apr 2026 20:39:24 +0000 (21:39 +0100)
When /proc is bind-mounted read-only (common in mock/Koji buildroots,
containers, and other sandboxed environments), opening
/proc/sys/fs/binfmt_misc returns ELOOP if it is an automount point
that cannot be triggered in the read-only context.

Currently binfmt_mounted_and_writable() only handles ENOENT, so ELOOP
propagates as an error. This causes test-binfmt-util to fail with
SIGABRT and disable_binfmt() to log a spurious warning at shutdown.

Treat ELOOP and EACCES the same as ENOENT: binfmt_misc is not usably
available, return false.

Note: PR #37006 (merged April 2025) addressed ELOOP in the xstatfsat()
path, but the open() call in binfmt_mounted_and_writable() remained
unhandled.

Fixes #38070

src/shared/binfmt-util.c

index d21fd10136fb48bdd93685af8410316c37059d87..0faca5966341c8f5f8023309a6240f4c662490e1 100644 (file)
@@ -18,6 +18,12 @@ int binfmt_mounted_and_writable(void) {
         fd = RET_NERRNO(open("/proc/sys/fs/binfmt_misc", O_CLOEXEC | O_DIRECTORY | O_PATH));
         if (fd == -ENOENT)
                 return false;
+        /* ELOOP happens when binfmt_misc is an automount point under a read-only bind mount of /proc —
+         * the kernel cannot trigger the automount and returns ELOOP instead. Common in mock/Koji buildroots. */
+        if (fd == -ELOOP || ERRNO_IS_NEG_PRIVILEGE(fd)) {
+                log_debug_errno(fd, "Failed to open /proc/sys/fs/binfmt_misc, ignoring: %m");
+                return false;
+        }
         if (fd < 0)
                 return fd;