Skip to content

LinuxDerivationBuilder: Use FD-based mounting API when available#15955

Open
xokdvium wants to merge 1 commit into
masterfrom
better-mounting
Open

LinuxDerivationBuilder: Use FD-based mounting API when available#15955
xokdvium wants to merge 1 commit into
masterfrom
better-mounting

Conversation

@xokdvium
Copy link
Copy Markdown
Contributor

@xokdvium xokdvium commented Jun 1, 2026

Motivation

We now use open_tree/move_mount syscalls when available. glibc version support shouldn't be too much of a concern at this point - the wrappers have been added in glibc 2.36.

There also was not a whole lot of validation of the sandbox paths, which is now fixed too (., .. filename are rejected, everything escaping the chroot is too).

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Jun 1, 2026
Comment thread src/libstore/linux/build/linux-derivation-builder.cc
@xokdvium
Copy link
Copy Markdown
Contributor Author

xokdvium commented Jun 1, 2026

Amazing, musl still doesn't have open_tree/move_mount wrappers :(

We now use open_tree/move_mount syscalls when available. glibc version support
shouldn't be too much of a concern at this point - the wrappers have been added in
glibc 2.36.

There also was not a whole lot of validation of the sandbox paths, which
is now fixed too (`.`, `..` filename are rejected, everything escaping
the chroot is too).
@xokdvium
Copy link
Copy Markdown
Contributor Author

xokdvium commented Jun 2, 2026

Also fixed the build with musl

@xokdvium xokdvium requested a review from Mic92 June 2, 2026 00:04
@Lillecarl
Copy link
Copy Markdown

If /nix/store is writeable at the source the bind mounts in the sandbox will be writeable too. Is it out of scope to control the read-only state of the sandbox mounts?

@xokdvium
Copy link
Copy Markdown
Contributor Author

xokdvium commented Jun 2, 2026

That's already the case, nothing has changed wrt to that. We have file level permissions to make stuff read-only, though I agree that it might be feasible to mount readonly, but I'm not sure how badly it would break things in practice. It might have ossified already enough that it would be a breaking change. I've done that previously for the new jail-based FreeBSD derivation builder.

Comment on lines +101 to +104
"/foo/.."
"/foo/."
"/.."
"/."
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably needs a few more tests.

Comment thread src/libstore/linux/build/linux-derivation-builder.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants