Skip to content

[v249] make pid1 namespace code independent of umask#148

Merged
keszybz merged 5 commits intosystemd:v249-stablefrom
aszlig:backport-21320
Jan 11, 2022
Merged

[v249] make pid1 namespace code independent of umask#148
keszybz merged 5 commits intosystemd:v249-stablefrom
aszlig:backport-21320

Conversation

@aszlig
Copy link
Contributor

@aszlig aszlig commented Nov 30, 2021

On NixOS we have a special confinement mode which creates a chroot of all the individual store paths needed for the services as BindReadOnlyPaths. This works fine unless the services in question use a more restrictive UMask, which then gets applied to all the directories leading up to the mount point. We tracked this in NixOS/nixpkgs#147599 and after this got reported in systemd/systemd#21548, it turned out that the fix for this is already in the main branch.

In systemd/systemd#21548 (comment), we got pointed to systemd/systemd#21320 which indeed fixes our issue.

We do currently have a very limited workaround to address the issue, but it involves adding dummy tmpfs instances and doesn't work for all bind mounts.

In NixOS/nixpkgs#147639 (comment) the original reporter and I already had a discussion on how to proceed and while I'm not sure on what's the policy on backports, I decided to hereby propose to backport systemd/systemd#21320.

Cc: @martinetd

(cherry picked from commit d73020f)
… umask

Let's reset the umask during the whole namespace_setup() logic, so that
all our mkdir() + mknod() are not subjected to whatever umask might
currently be set.

This mostly moves the umask save/restore logic out of
mount_private_dev() and into the stack frame of namespace_setup() that
is further out.

Fixes #19899

(cherry picked from commit cdf42f9)
Let's make all code in namespace.c robust towards weird umask. This
doesn't matter too much given that the parent dirs we deal here almost
certainly exist anyway, but let's clean this up anyway and make it fully
clean.

(cherry picked from commit 3044343)
Inspired by the test case described in #19899

(cherry picked from commit 875afa0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants