Allow gc-ing with a rootless daemon#15026
Conversation
5b752cb to
12e2277
Compare
|
I'm not entirely convinced that we need to remove the libutil dependency. The C++ standard library lacks many useful tools that have been provided in libutil (e.g. string parsing, calling external programs, parsing environment), and reimplemting those would require duplication and may result in lower code quality in libroots. We would also need to reimplement the assert-fail wrapper from |
Why is that an issue? It seems like we can reuse a bunch of code without reimplementing everything from scratch. Also, I've been a bit stumped by which issue we are solving here exactly. What's the threat model? I don't see any security gains from this at least for NixOS, since a pwned daemon would allow trivial privilege escalation anyway (by replacing a sensitive store path). |
|
This is not useful for NixOS, but it does reduce nix's attack surface on non-NixOS Linux. |
|
I am somewhat confused why the original code uses |
|
So the use-case would be:
One alternative: We can probably just disable runtime root scanning if we don't have CAP_SYS_PTRACE and just scan whatever we have access to. Then the usecase with a multi-user install on non-NixOS could just have a group that the daemon runs as. Runtime roots won't be found without CAP_SYS_PTRACE, but presumably any security-conscious use-case would never allow ptracing arbitrary processes anyway. I think the more productive ways to harden the daemon are:
|
12e2277 to
effed85
Compare
The new "libroots" library intentionally does not rely on other parts of the nix codebase, so as to allow creating a minimal daemon to find roots while the rest of nix is left unprivileged. Co-Authored-By: Théophane Hufschmitt <theophane.hufschmitt@tweag.io> Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems>
effed85 to
a6b53e1
Compare
|
Replaced by #15143 |
Motivation
Determining garbage collection roots requires root access, but little other of nix does. If garbage collection is moved out to a minimal external daemon and the nix store is owned as an unprivileged user then nix can run with no root permissions, reducing the damage if it is exploited.
Context
This is a replacement for #5380 and a fix for #5208. I determined a new branch was easier than squashing and rebasing so many commits after major changes to the nix codebase.
The main gc code is moved out of
libstoreinto a newlibroots, which can be accessed by bothlibstoreand the newnix-roots-daemon.This is still a draft as the
nix-roots-daemonhas not been written andlibrootsstill relies onlibutil.Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.