Re: [RFC PATCH v7 00/26] userland: Userland containers

From: Jarkko Sakkinen

Date: Sat Nov 28 2026 - 05:36:48 EST


On Sat, Nov 28, 2026 at 11:53:06AM +0200, Jarkko Sakkinen wrote:
> On Sat, Nov 28, 2026 at 04:50:42AM +0300, Askar Safin wrote:
> > On Sat, Nov 28, 2026 at 2:15 AM Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:
> > > thinking more sequencing than data structures. I.e. I have a game where
> > > I need to end up to process creation without embryonic state, and add
> > > just enough weight to kernel to support that outcome, and that leads
> > > to ~2K'ish LOC of extra kernel complexity.
> >
> > So you don't have embryonic state? I don't like this.
> >
> > Let's assume the following situation. Userland's PID 1 is already running.
> > Our container manager attempts to spawn yet another process into userland.
> > As well as I understand, it should do clone3 with CLONE_INTO_USERLAND,
> > and then execve.
> > This creates time hole when there is process, which already runs inside
> > userland (i. e. its PID namespace and other namespaces), but runs
> > container manager's binary and have container manager's mm.
> > This invites for bugs. Other processes, which already run inside userland,
> > may somehow take advantage of this.
> > For example, see section "CVE-2019-5736 Is a Very Very Very Bad
> > Privilege Escalation to Host Root"
> > of https://brauner.io/2019/02/12/privileged-containers.html .
> > So, here I like embryos.
>
> We all have things that I like but let's talk about facts instead.
>
> CVE-2019-5736 was also not a sibling process racing the pre-execve
> window: it happened inside execve() itself via binfmt_script resolving
> container-controlled #!/proc/self/exe.
>
> CLONE_INTO_USERLAND rejects CLONE_VM, CLONE_FILES, CLONE_FS, and
> CLONE_SIGHAND, keeps exec_state->user_ns in the caller's outer user
> namespace, and resets exec_state->dumpable to suid_dumpable (0) when
> installing userland->user_ns. Until execve(), ptrace_may_access() checks
> CAP_SYS_PTRACE against the outer user_ns, so processes inside the
> userland cannot ptrace the child or access /proc/<pid>/{exe,mem,fd}.

The build phase on struct userland (USERLAND_INIT, before any task
exists) lets clone3(CLONE_INTO_USERLAND) stay an atomic copy_process()
step and execve() stay as it is.

It fully lives in the *pre-existing syscall paths*".

Br, Jarkko