Re: [RFC PATCH v5 12/25] rootns: Track init lifecycle via copy_process() and pid_namespace
From: Jarkko Sakkinen
Date: Fri Nov 20 2026 - 20:32:30 EST
On Sat, Nov 21, 2026 at 02:08:31AM +0200, Jarkko Sakkinen wrote:
> A root namespace needs to record its init thread group's PID when
> bootstrapped and capture its exit status once all processes in the root
> namespace have terminated, without serializing normal fork() and exit()
> paths inside the container.
>
> Commit the bootstrap child reaper and bind pid_ns->rootns in
> copy_rootns() after attach_pid(PIDTYPE_PID), and invoke exit_rootns()
> from zap_pid_ns_processes() after the root namespace's PID namespace has
> killed and reaped all member tasks.
>
> Co-developed-by: David Howells <dhowells@xxxxxxxxxx>
> Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
> Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
ROOTNS_GET_NSFD will be the only surviving ioctl, which make access
control wise sense.
This leaves room for ROOTNS_SHARE_NSFD, which would share a namespace
from host. This makes whole a lot more sense than unsharing security
wise as it is allow listing (instead of deny listing).
It can be post-clone3 disabled. This is what we do in SGX driver i.e.,
have build phase enabled ioctls.
Br, Jarkko