|
|
Log in / Subscribe / Register

Variant for chroot ?

Variant for chroot ?

Posted Mar 14, 2026 1:35 UTC (Sat) by geofft (subscriber, #59789)
In reply to: Variant for chroot ? by wtarreau
Parent article: Practical uses for a null filesystem

> enter it and lazy-unmount it so that once the caller dies, it's automatically unmounted

This is already the behavior of, say, a tmpfs in a mount namespace. It's reference-counted and once the last process referencing it dies, the tmpfs is cleaned up. You can see this very clearly by creating a large file and looking at memory usage before/after a kill -9 of the owning process.

Mostly for amusement purposes, I wrote a mkdtemp() alternative that works by creating a child process in a new unprivileged user+mount namespace and having it pass back a handle to a tmpfs. https://ldpreload.com/p/verytmp.c

A friend ported it to Rust and has a slightly more detailed writeup: https://blinsay.com/posts/verytmp/

(nullfs appears to not be mountable inside a userns, largely because it's a global singleton. So you don't actually need to garbage-collect it, but I guess this also means you might not be a way to actually get to it from a regular userspace process.)


to post comments

Variant for chroot ?

Posted Mar 16, 2026 9:24 UTC (Mon) by taladar (subscriber, #68407) [Link]

At first I thought mounting nullfs might be safer to allow for a user than most other filesystems since it can not replace the content it is mounted over, just hide it, but I guess there is the edge case of config.d style directories where you could cut out some parts of the configuration for some setuid root tool like sudo that way.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds