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
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;