Skip to content

nspawn: Stop overmounting /sys and /proc when a user namespace is used#40815

Draft
daandemeyer wants to merge 1 commit intosystemd:mainfrom
daandemeyer:nspawn-nesting
Draft

nspawn: Stop overmounting /sys and /proc when a user namespace is used#40815
daandemeyer wants to merge 1 commit intosystemd:mainfrom
daandemeyer:nspawn-nesting

Conversation

@daandemeyer
Copy link
Collaborator

When the container runs in a user namespace, we don't need to protect /proc and /sys by overmounting things. In fact this is actively harmful as it prevents nested systemd-nspawn from working as to mount procfs and sysfs in a container it cannot be overmounted or the kernel will refuse the mount.

To make nesting possible, let's stop overmounting parts of /proc and /sys when user namespaces are in use.

When the container runs in a user namespace, we don't need to protect
/proc and /sys by overmounting things. In fact this is actively harmful
as it prevents nested systemd-nspawn from working as to mount procfs and
sysfs in a container it cannot be overmounted or the kernel will refuse
the mount.

To make nesting possible, let's stop overmounting parts of /proc and /sys
when user namespaces are in use.
return true;

r = namespace_is_init(NAMESPACE_USER);
if (r < 0 && !IN_SET(r, -EBADR, -ENOSYS))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how could this return EBADR? it's our internal struct data after all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants