From: Samuel Dainard Date: Tue, 28 Apr 2026 15:57:26 +0000 (+0000) Subject: binfmt-util: handle ELOOP/EACCES from automount in read-only bind mounts X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f2189ca2544cce99c2aa7a35881007830dc221a;p=thirdparty%2Fsystemd.git binfmt-util: handle ELOOP/EACCES from automount in read-only bind mounts 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 --- diff --git a/src/shared/binfmt-util.c b/src/shared/binfmt-util.c index d21fd10136f..0faca596634 100644 --- a/src/shared/binfmt-util.c +++ b/src/shared/binfmt-util.c @@ -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;