Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SimSaladin
Copy link

Motivation

This extends the sandbox-paths syntax to allow the extra optional suffix :ro for marking that path so as to be mounted read-only in the sandbox. The suffix is excluded from the mounted source or target path. It will only cause the mount MS_RDONLY flag to be set.

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) with MS_RDONLY. For some reason single mount 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 from util-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() and move_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 a PATH 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

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 <[email protected]>
@SimSaladin SimSaladin requested a review from Ericson2314 as a code owner June 2, 2025 22:52
@tomberek tomberek added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants