-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Read-only sandbox paths mounts (Linux) #13315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
2eaca52
to
97c779b
Compare
Signed-off-by: Samuli Thomasson <samuli.thomasson@pm.me>
some of the functional tests that run config check wouldn't tolerate some oddities in `PATH`, something like a null string entry (e.g. `::` in the middle or a trailing `:`) I think. This allows the test pass. Signed-off-by: Samuli Thomasson <samuli.thomasson@pm.me>
Signed-off-by: Samuli Thomasson <samuli.thomasson@pm.me>
Signed-off-by: Samuli Thomasson <samuli.thomasson@pm.me>
97c779b
to
1b2c828
Compare
|
||
#ifdef __linux__ | ||
/* Options to set when readOnly=true */ | ||
constexpr static MountOpt readOnlyDefaults[] = { ro, nodev, noexec, nosuid, noatime }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, seems odd to have "readOnly" imply noexec
, noatime
etc. I would expect a readonly mount to still be executable by default.
strictatime = MS_STRICTATIME, /* overrides any atime/relatime */ | ||
private_ = MS_PRIVATE, | ||
slave = MS_SLAVE, | ||
unbindable = MS_UNBINDABLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if all of these mount options make sense to expose. In particular, the mount propagation flags seem a bit scary. We don't want the builder to be able to have mounts propagate out of the sandbox...
We should probably set MS_NOSUID
unconditionally since it's nice for security. Though unfortunately it doesn't prevent the creation of suid binaries.
Motivation
This extends the
sandbox-paths
syntax to allowthe extra optional suffixextended JSON syntax for marking that path so as to be mounted read-only in the sandbox.:ro
The suffix is excluded from the mounted source or target path. It will only cause the mountThe new "readOnly" option enablesMS_RDONLY
flag to be set.MS_RDONLY
and a few other mount-point flags for the affected bind-mount.Context
...well, technically we make then another
mount(2)
call on the target path right after mounting the path for the first time, in order to do a second mount (or rather remount,MS_REMOUNT
) withMS_RDONLY
. For some reason singlemount
syscall can't both create a new bind-mount and assign the read-only flag to it (its mount-point really) ... or propagation properties for that matter.The
mount(8)
cli fromutil-linux
abstracts over this with a second syscall as necessary as well (more even sometimes, it seems).There's a better, modern API since about linux 5.12 with
open_tree()
,mount_setattr()
andmove_mount()
. Probably doesn't really make a difference until there's some need or want for those features though.One of the commits (2eaca52) is not related to to the bulk of the changes in this. it's a small change to fix a certain edge-case (think user launching
nix
or running tests with aPATH
that still works, for all intents and purposes, but looks like it fell through a slipstream portal sideways).add 👍 to pull requests you find important.
the nix maintainer team uses a github project board to schedule and track reviews