OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>,
	Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH RFC hci-8.2 1/2] ve: mark a host task entering a pseudosuper VE as a setup task
Date: Thu, 19 Nov 2026 22:49:02 +0100	[thread overview]
Message-ID: <20261119-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v1-1-06fa0b8994a8@virtuozzo.com> (raw)
In-Reply-To: <20261119-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v1-0-06fa0b8994a8@virtuozzo.com>

ve_setup_task() marks a task the host sends into a VE as
VD_VE_SETUP_TASK only while the VE is VE_STATE_STARTING, and as
VD_VE_ENTER_TASK afterwards. While the VE is pseudosuper, a setup task
is reachable only from another setup task.

libvzctl before 10.0.144 writes START to ve.state, which ends in
VE_STATE_RUNNING, before it configures the disk: a helper then enters
the init task's namespaces one by one through setns(), the VE namespace
among them, and opens /proc/<init>/ns/mnt. It enters a running VE, so
it becomes an ENTER task, and pseudosuper is cleared only after the
setup, so the init task, a setup task, is still hidden from it.

Every container start with such a libvzctl fails:

  Failed to open /proc/<pid>/ns/mnt: Permission denied
  Failed to configure disk
  Cancel init execution

libvzctl 10.0.144 and newer open the namespaces before joining any and
are not affected.

A host task entering a VE that is still pseudosuper is part of its
setup whatever ve.state says: mark it VD_VE_SETUP_TASK while
is_pseudosuper is set. Container binaries such a helper execs still
drop the mark on exec, so they gain nothing.

Fixes: a7d797d177e7 ("ve: hide the tasks that set up a starting VE from the rest of it")
https://virtuozzo.atlassian.net/browse/VSTOR-156164

Feature: trace: prohibit tracing sensitive tasks from CT
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 kernel/ve/ve.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 076892a750cfc..7323ea2053ac6 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1899,18 +1899,19 @@ void ve_setup_task(struct task_struct *task, struct ve_struct *old_ve,
 		return;
 
 	/*
-	 * A task the host sends into a starting VE is a setup task, one it
-	 * sends into a started VE is hidden from the tasks of the VE. A setup
-	 * task leaving a VE that is still pseudosuper was sent by the host
-	 * too. The mark goes to the mm, which may be shared, so a task coming
-	 * from a container never gets either. A setup task leaving a VE that
-	 * is not pseudosuper drops the mark: after pseudosuper is cleared it
-	 * cannot be told from the restored processes.
+	 * A task the host sends into a VE (from ve0, or a setup task of a
+	 * VE still pseudosuper) becomes a setup task if the VE starts or
+	 * stays pseudosuper, else one hidden from the VE's tasks.
+	 *
+	 * The mark lives in the mm, which may be shared, so a task from a
+	 * container keeps its mark, except a setup mark of a VE that left
+	 * pseudosuper: it is an ordinary task now.
 	 */
 	if (mm && old_ve != ve) {
 		if (ve_is_super(old_ve) ||
 		    ve_vps_dumpable(mm, old_ve) == VD_VE_SETUP_TASK)
-			mm->vps_dumpable = ve->state == VE_STATE_STARTING ?
+			mm->vps_dumpable = ve->state == VE_STATE_STARTING ||
+					   ve->is_pseudosuper ?
 					   VD_VE_SETUP_TASK : VD_VE_ENTER_TASK;
 		else if (mm->vps_dumpable == VD_VE_SETUP_TASK)
 			mm->vps_dumpable = VD_PTRACE_COREDUMP;

-- 
2.43.0

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

  reply	other threads:[~2026-11-19 21:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 21:49 [Devel] [PATCH RFC hci-8.2 0/2] ve: Container start on the 26.3 kernel with libvzctl before 10.0.144 Konstantin Khorenko
2026-11-19 21:49 ` Konstantin Khorenko [this message]
2026-11-19 21:56   ` [Devel] [PATCH RFC hci-8.2 1/2] ve: mark a host task entering a pseudosuper VE as a setup task no-reply
2026-11-19 21:49 ` [Devel] [PATCH RFC hci-8.2 2/2] selftests/ve: check a host task entering a pseudosuper VE reaches its init Konstantin Khorenko
2026-11-19 21:54   ` no-reply

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=20261119-b4-prep-khorenko-vstor-156164-ve-setup-task-pseudosuper-v1-1-06fa0b8994a8@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=mirian.shilakadze@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox