All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
	Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1] ve: start the kernel threads of a container in its ve namespace
Date: Tue, 03 Nov 2026 11:10:40 +0100	[thread overview]
Message-ID: <179370064092.2387336.10899245587121249748.b4-review@b4> (raw)
In-Reply-To: <20261103020252.2464400-1-eva.kurchatova@virtuozzo.com>

On Tue, 03 Nov 2026 04:02:34 +0200, Eva Kurchatova wrote:
> The kthreadd and khelper of a container are forked from a worker that
> takes over the namespaces, root, credentials and cgroups of the task
> starting the container, but not its ve namespace, which nsproxy does
> not carry.

Only kthreadd is forked from the worker. ve_create_kthreadd() points
ve->kthreadd_worker at it for that one fork, then switches to the own
worker of kthreadd, and ve_start_kthreadd() destroys the worker.
ve_start_umh() runs after that, so khelper is forked by the container
kthreadd and inherits the ve namespace from it. Please fix the
sentence, e.g. "The kthreadd of a container is forked from a worker
... Every other kernel thread of the container, khelper included, is
forked from that kthreadd."

> As task_ve follows the ve namespace, they run as host tasks,
> and so do the usermode helpers the container starts: a core dump to a
> pipe in a container fails, because the host may not execute a file
> from an untrusted container disk.

The patch also fixes nfsd in a container. Its threads are created
through the container kthreadd (serv->ve_virtualized), so they had
get_exec_env() == ve0, and nfsd4_umh_cltrack_upcall() passed that to
call_usermodehelper_ve(): the host ran its own nfsdcltrack in the host
root for a client of the container. Worth one sentence, it is a worse
case than the core dump.

> +	/* task_ve follows the ve namespace, which nsproxy does not switch */
> +	switch_ve_namespace(current, get_ve_ns(target->ve_ns));

Optional: "which is not part of nsproxy" is what the comment means.
The FIXME in switch_ve_namespace() and commit_nsset() switch the ve
namespace last, after creds; moving the call after
cgroup_attach_task_all() would keep the two paths alike. Nothing
depends on the order today.

Pasha, could you please review it as well? It changes how the
container kthreads get their task_ve after your 4d033dd01fd3.

With that fixed:

Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-03 10:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  2:02 Eva Kurchatova
2026-11-03  2:08 ` no-reply
2026-11-03 10:10 ` Konstantin Khorenko [this message]
2026-11-03 13:13 ` Pavel Tikhomirov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179370064092.2387336.10899245587121249748.b4-review@b4 \
    --to=khorenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=ptikhomirov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.