nspawn: actually mask certain files under /proc/#40833
Open
mrc0mmand wants to merge 1 commit intosystemd:mainfrom
Open
nspawn: actually mask certain files under /proc/#40833mrc0mmand wants to merge 1 commit intosystemd:mainfrom
mrc0mmand wants to merge 1 commit intosystemd:mainfrom
Conversation
/run/systemd/inaccessible/ exists only on host - in the container we have /run/host/inaccessible/, and since all the inaccessible mounts have MOUNT_IN_USERNS we need to use the latter one, otherwise the masking gets silently skipped: ~# SYSTEMD_LOG_LEVEL=debug systemd-nspawn -q --directory=foo ls -la /proc/kallsyms ... Bind-mounting /run/systemd/inaccessible/reg on /proc/kallsyms (MS_BIND "")... Failed to mount /run/systemd/inaccessible/reg (type n/a) on /proc/kallsyms (MS_BIND ""): No such file or directory Changing mount flags /proc/kallsyms (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND "")... Failed to mount n/a (type n/a) on /proc/kallsyms (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND ""): Invalid argument Bind-mounting /run/systemd/inaccessible/reg on /proc/kcore (MS_BIND "")... Failed to mount /run/systemd/inaccessible/reg (type n/a) on /proc/kcore (MS_BIND ""): No such file or directory Changing mount flags /proc/kcore (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND "")... Failed to mount n/a (type n/a) on /proc/kcore (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_REMOUNT|MS_BIND ""): Invalid argument ... Inner child finished, invoking payload. -r--r--r--. 1 root root 0 Feb 25 13:19 /proc/kallsyms
yuwata
approved these changes
Mar 2, 2026
Member
|
Could you also add test case with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/run/systemd/inaccessible/ exists only on host - in the container we have
/run/host/inaccessible/, and since all the inaccessible mounts have
MOUNT_IN_USERNS we need to use the latter one, otherwise the masking
gets silently skipped:
Now, this has been broken for a long time (I guess since de40a30, /cc @poettering ). And due to this, some folks actually started relying on this behavior. I know this because I noticed this issue due to one such use case - recently we got an internal report that kernel folks can't build kernels in RHEL 8 mock environments when using the nspawn isolation, because
/proc/kallsymsis inaccessible there. That's before de40a30 and hence the masking works there as expected:But later RHEL/Fedora/systemd versions don't mask these files properly, so they're still readable, which won't be possible after fixing it. Unfortunately, I don't think there's currently a way how to "override" this masking to "unbreak" these use cases, as
--bind*=and friends won't work there (maybeSYSTEMD_NSPAWN_API_VFS_WRITABLE=yeswould work, but it's ugly and I'm not sure about all the implications). Not sure what to do in this case, but I suspect that this might affect Fedora kernel builds as well if fixed (/cc @keszybz).