[Devel] [PATCH RFC hci-8.2 1/2] ve: mark a host task entering a pseudosuper VE as a setup task
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Nov 20 00:49:02 MSK 2026
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 at 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
More information about the Devel
mailing list