Nix needs relocatable binaries

49 points by polywolf


davidbalbert

I would love to see $ORIGIN support for PT_INTERP in the Linux kernel. I've done static wrapper binaries for this before, and I've seen a number of other attempts (here's a good one). They're all glorious, wonderful hacks. But hacks nonetheless.

I haven't grokked the security implications. It would be helpful to see them laid out.

Pretty sure Solaris supports this, so maybe there's a way to do this securely. I'm struggling to find a reference, but the execve(2) man page has this under ENOEXEC:

The PT_INTERP program header for a setuid or setgid process image file has a relative path, or employs the $ORIGIN token

Cloudef

Won't many software have hardcoded paths and other constants defined at build-time that would also require recompilation for the software to work correctly?

LeahNeukirchen

The dcrt1 patch for musl (by rcombs) solves this in userspace.

tuxes

Yesterday I commented:

Farid has many recent foundational posts on Nix. I'm hoping he's porting store-based OSs to Buck, as part of his recent role at Meta.

Today, this post brings these hopes ever closer!

If you are using tools like Bazel or Buck2 they likely already employ their own sandboxing via namespacing for builds. Integrating Nix into these ecosystems becomes incredibly impractical because we run into nested user namespace and mount restrictions.

lilyball

If we switch to using relative paths, wouldn't that potentially break hardlinks to the binary?