OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE
@ 2026-11-17 10:13 Mirian Shilakadze
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from Mirian Shilakadze
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

While a container starts or is restored, ve.pseudosuper is on and its
relaxations apply to every process in the container. The container's
own binaries that vzctl and CRIU run in that window get them too, such
as quotaon at start and the tee that vz-rst-action runs at post-restore.
Such a binary can rewrite the container's root memory.max, skip the
mount limit and the mount option filter, use NETLINK_REPAIR, or clear
pseudosuper early. During a restore it can also open /proc/<pid>/fd of
CRIU's restoring tasks and take CRIU's log, its /proc fd and the
transport socket.

This series marks the tasks the host sends into a starting VE as setup
tasks. Fork keeps the mark, exec drops it, and only a task coming from
the host gets it.

- 1/6 passes ve_setup_task() the VE a task comes from
- 2/6 hides only the tasks the host sends into a VE, in any state but
  starting
- 3/6 marks setup tasks and lets them be reached only by each other
  while the VE is pseudosuper
- 4/6 to 6/6 give the pseudosuper relaxations only to setup tasks: the
  container's root cgroup files, the mount filter and limit, and the
  rest. A host task that joins the VE after it has started, such as the
  CRIU helper that mounts proc for a nested pid namespace, still skips
  the mount limit.

Once pseudosuper is cleared, the restored processes are ordinary
container processes again. vzctl and CRIU need no change.

Changes since v1, after Konstantin's review and Sashiko's:
- a host task that moves from a starting VE into a running one is
  hidden there again: a setup task leaving a VE that is still
  pseudosuper counts as sent by the host (2/6 and 3/6)
- a task that setns()es into its own VE keeps its mark (2/6 and 3/6)
- ve_setup_task() runs before the old VE namespace is put, which may
  drop the last reference to the VE it now reads (1/6)
- 5/6 has a new subject and uses ve_current_is_host_task() instead of
  the open-coded test in the mount limit
- 3/6 adds ve_current_has_mark(), which ve_current_is_pseudosuper()
  and the 5/6 helper share
- the comments on VD_VE_SETUP_TASK, ve_current_is_pseudosuper(),
  ve_pseudosuper_write(), ve_devmnt_process() and
  devcgroup_legacy_check_permission() describe the new checks
- the 2/6 message says why a container task must not get
  VD_VE_ENTER_TASK and that a task entering its nested VE is no longer
  hidden there, and its first paragraph is reworded

- Link to v1: http://lore.virtuozzo.com/20261116104552.102938-1-mirian.shilakadze@virtuozzo.com

Tested on kernel 6.12.0-211.75.1.24.1.vz10 with this series, which
applies there unchanged, on a VHI 8.1 node with vzctl 10.0.159 and
criu 4.2.1.18, stock against patched:
- a probe in place of the container's quotaon and tee: on stock it
  reads the fds of every restoring task, restore.log included, sets
  NETLINK_REPAIR and rewrites the root memory.max, on patched all of
  it is refused
- the same probe gains nothing by moving into a nested VE and
  unsharing it from a vfork child that shares its mm
- a host task that enters a starting VE, then joins a running
  container and its user namespace without exec: hidden on stock and
  on patched. With v1 the container could read its fds.
- a host task that joins the container and its user namespace without
  exec stays hidden, and becomes visible once it execs
- a container with a nested pid namespace restored with its mount
  limit lowered to 10: restores. Without the exemption in 5/6 the
  proc mount for that namespace failed with ENOMEM.
- after resume the container sees its restored processes and they
  dump core, and start, stop, suspend, resume, a second disk and a
  container at its mount limit behave as on stock
- CRIU zdtm in the ve flavor, with every userns test forced into it:
  441 passed, 8 failed, all 8 fail on stock too. bridge, sit and
  socket_udplite cannot set up their devices in a VE on that node.
- vzctl pytest 10.0.159: 1377 passed, 0 failed

Mirian Shilakadze (6):
  ve: tell ve_setup_task() which VE the task comes from
  ve: hide only the tasks the host sends into a VE
  ve: hide the tasks that set up a starting VE from the rest of it
  cgroup: give the CT root file writes and hidden roots only to setup
    tasks
  fs: keep the mount relaxations of a pseudosuper VE from container
    binaries
  ve: give the remaining pseudosuper relaxations only to setup tasks

 fs/coredump.c            |  2 +-
 fs/namespace.c           | 12 +++---
 include/linux/mm_types.h |  3 ++
 include/linux/ve.h       | 12 +++++-
 kernel/cgroup/cgroup.c   |  4 +-
 kernel/ptrace.c          | 23 +++++++++--
 kernel/sys.c             |  2 +-
 kernel/ve/ve.c           | 89 +++++++++++++++++++++++++++++++++++-----
 kernel/ve/ve_namespace.c | 10 +++--
 net/netlink/af_netlink.c |  2 +-
 security/device_cgroup.c |  8 ++--
 11 files changed, 132 insertions(+), 35 deletions(-)

--
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
@ 2026-11-17 10:13 ` Mirian Shilakadze
  2026-11-17 10:20   ` no-reply
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 2/6] ve: hide only the tasks the host sends into a VE Mirian Shilakadze
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

The next changes mark a task entering a VE by where it comes from. Pass
the VE the task leaves to ve_setup_task(), and call it before the old
VE namespace is put, as that may drop the last reference to that VE.
No functional change.

Feature: ve: ve generic structures
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 include/linux/ve.h       |  6 ++++--
 kernel/ve/ve.c           |  3 ++-
 kernel/ve/ve_namespace.c | 10 +++++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index a400d21593b2..2fe1a1c9ff55 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -282,7 +282,8 @@ int ve_net_hide_sysctl(struct net *net);
 
 extern bool is_ve_init_net(const struct net *net);
 
-void ve_setup_task(struct task_struct *p, struct ve_struct *ve);
+void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
+		   struct ve_struct *ve);
 
 void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool));
 
@@ -390,7 +391,8 @@ static inline struct cgroup_subsys_state *css_ve_root1(
 static inline int vz_security_family_check(struct net *net, int family, int type) { return 0; }
 static inline int vz_security_protocol_check(struct net *net, int protocol) { return 0; }
 
-static inline void ve_setup_task(struct task_struct *p, struct ve_struct *ve) { }
+static inline void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
+				 struct ve_struct *ve) { }
 
 static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { }
 
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index cdfd03416b39..72a2834707c5 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1831,7 +1831,8 @@ int ve_get_cpu_stat(struct ve_struct *ve, struct kernel_cpustat *kstat)
 }
 EXPORT_SYMBOL(ve_get_cpu_stat);
 
-void ve_setup_task(struct task_struct *task, struct ve_struct *ve)
+void ve_setup_task(struct task_struct *task, struct ve_struct *old_ve,
+		   struct ve_struct *ve)
 {
 	if (ve == &ve0)
 		return;
diff --git a/kernel/ve/ve_namespace.c b/kernel/ve/ve_namespace.c
index 6b12bcd605ea..890fa126bbdd 100644
--- a/kernel/ve/ve_namespace.c
+++ b/kernel/ve/ve_namespace.c
@@ -106,6 +106,7 @@ int copy_ve_ns(unsigned long flags, struct task_struct *p)
 {
 	struct user_namespace *user_ns = task_cred_xxx(p, user_ns);
 	struct ve_namespace *old_ve_ns = p->ve_ns;
+	struct ve_struct *old_ve = p->task_ve;
 	struct ve_namespace *new_ve_ns;
 
 	if (!(flags & CLONE_NEWVE)) {
@@ -123,7 +124,7 @@ int copy_ve_ns(unsigned long flags, struct task_struct *p)
 	p->ve_ns = new_ve_ns;
 	p->task_ve = new_ve_ns->ve;
 
-	ve_setup_task(p, p->task_ve);
+	ve_setup_task(p, old_ve, p->task_ve);
 
 	return 0;
 }
@@ -161,6 +162,7 @@ void free_ve_ns(struct ve_namespace *ns)
 void switch_ve_namespace(struct task_struct *p, struct ve_namespace *new)
 {
 	struct ve_namespace *old;
+	struct ve_struct *old_ve;
 
 	/*
 	 * FIXME
@@ -170,14 +172,16 @@ void switch_ve_namespace(struct task_struct *p, struct ve_namespace *new)
 
 	scoped_guard(task_lock, p) {
 		old = p->ve_ns;
+		old_ve = p->task_ve;
 		p->ve_ns = new;
 		p->task_ve = new ? new->ve : &ve0;
 	}
 
+	/* @old may hold the last reference to @old_ve */
+	ve_setup_task(p, old_ve, p->task_ve);
+
 	if (old)
 		put_ve_ns(old);
-
-	ve_setup_task(p, p->task_ve);
 }
 
 void exit_ve_namespace(struct task_struct *p)
-- 
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Devel] [PATCH hci-8.2 v2 2/6] ve: hide only the tasks the host sends into a VE
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from Mirian Shilakadze
@ 2026-11-17 10:13 ` Mirian Shilakadze
  2026-11-17 10:22   ` no-reply
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it Mirian Shilakadze
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

ve_setup_task() marks a task entering a running VE VD_VE_ENTER_TASK,
which hides it from ptrace and /proc/<pid>/exe inside the VE. A
container task gets the mark too when it setns()es into its own VE or
enters a nested one, and a host task entering a stopping or stopped VE
is not hidden at all.

The mark says a task is the host's, a later change lets it skip the
mount limit of a pseudosuper VE, and it goes to the mm, which a
container task may share with others. So mark only tasks coming from
the host, in every VE state but starting, which the next change
handles. A task entering its nested VE is no longer hidden there. In a
pseudosuper VE the host's tasks cannot be told from the container's
yet, so a task leaving one is still marked until the next change.

Feature: trace: prohibit tracing sensitive tasks from CT
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 kernel/ve/ve.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 72a2834707c5..ff1c7f9b88c7 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1837,8 +1837,14 @@ void ve_setup_task(struct task_struct *task, struct ve_struct *old_ve,
 	if (ve == &ve0)
 		return;
 
-	/* this prohibits ptracing of task entered to VE from host system */
-	if (VE_IS_RUNNING(ve) && task->mm)
+	/*
+	 * A task the host sends into a started VE is hidden from the tasks of
+	 * the VE. The mark goes to the mm, which may be shared, so a task
+	 * coming from a container never gets it, unless the container is
+	 * pseudosuper: the host's tasks there cannot be told from its own.
+	 */
+	if (task->mm && old_ve != ve && ve->state != VE_STATE_STARTING &&
+	    (ve_is_super(old_ve) || old_ve->is_pseudosuper))
 		task->mm->vps_dumpable = VD_VE_ENTER_TASK;
 
 	/* Drop OOM protection. */
-- 
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from Mirian Shilakadze
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 2/6] ve: hide only the tasks the host sends into a VE Mirian Shilakadze
@ 2026-11-17 10:13 ` Mirian Shilakadze
  2026-11-17 10:27   ` no-reply
  2026-11-17 11:40   ` Konstantin Khorenko
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks Mirian Shilakadze
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

CRIU's restoring tasks enter the VE before it runs, so they stay
VD_PTRACE_COREDUMP. A container binary run during the restore, such as
the tee that post-restore runs via vzctl exec3, can open their
/proc/<pid>/fd and take CRIU's log, its /proc fd and the transport
socket.

Mark a task the host sends into a starting VE as VD_VE_SETUP_TASK.
Fork keeps the mark and exec drops it. While the VE is pseudosuper, such
a task dumps no core and is reachable only from another setup task of
the VE, so CRIU's tasks still reach each other and what they exec does
not. Once pseudosuper is cleared the mark counts as VD_PTRACE_COREDUMP,
so the restored processes become ordinary ones. Of the tasks leaving a
pseudosuper VE, only its setup tasks are marked in the VE they enter,
so a host task that moves on to a running VE stays hidden there.

Feature: trace: prohibit tracing sensitive tasks from CT
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 fs/coredump.c            |  2 +-
 include/linux/mm_types.h |  3 ++
 include/linux/ve.h       |  4 +++
 kernel/ptrace.c          | 23 ++++++++++++---
 kernel/ve/ve.c           | 60 +++++++++++++++++++++++++++++++++++-----
 5 files changed, 80 insertions(+), 12 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index 3d15612e3493..6977c31aad59 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -618,7 +618,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
 		goto fail;
 
 	/* Avoid dumping sensitive tasks */
-	if (mm->vps_dumpable != VD_PTRACE_COREDUMP)
+	if (ve_vps_dumpable(mm, get_exec_env()) != VD_PTRACE_COREDUMP)
 		goto fail;
 	cred = prepare_creds();
 	if (!cred)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index befdf38ef855..53cb5ff32a23 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -1115,6 +1115,9 @@ extern struct mm_struct init_mm;
 #define VD_PTRACE_COREDUMP	1/* tasks with ptrace and coredump allowed */
 #define VD_LICDATA_ACCESS	2/* tasks accessed containers license data,
 				  * no ptrace and no coredump allowed */
+#define VD_VE_SETUP_TASK	3/* tasks the host sent into a starting VE,
+				  * reachable only from each other while it
+				  * is pseudosuper, VD_PTRACE_COREDUMP after */
 
 /* Pointer magic because the dynamic array size confuses some compilers. */
 static inline void mm_init_cpumask(struct mm_struct *mm)
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 2fe1a1c9ff55..56c310205394 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -284,6 +284,8 @@ extern bool is_ve_init_net(const struct net *net);
 
 void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
 		   struct ve_struct *ve);
+bool ve_current_is_pseudosuper(struct ve_struct *ve);
+int ve_vps_dumpable(struct mm_struct *mm, struct ve_struct *ve);
 
 void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool));
 
@@ -393,6 +395,8 @@ static inline int vz_security_protocol_check(struct net *net, int protocol) { re
 
 static inline void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
 				 struct ve_struct *ve) { }
+static inline bool ve_current_is_pseudosuper(struct ve_struct *ve) { return true; }
+#define ve_vps_dumpable(mm, ve)	((mm)->vps_dumpable)
 
 static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { }
 
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index faf60bb8ae2c..ff71c3e37bc1 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -284,11 +284,26 @@ static bool task_still_dumpable(struct task_struct *task, unsigned int mode)
 	 * whose mm was already dropped in exit_mm() or a kernel thread - cannot
 	 * have its vps_dumpable confirmed, so deny it. This closes the window
 	 * where a dying CT task could be inspected (e.g. an fd stolen via
-	 * pidfd_getfd()) after exit_mm() cleared ->mm.
+	 * pidfd_getfd()) after exit_mm() cleared ->mm. While its VE is
+	 * pseudosuper, a setup task is only inspectable by another one.
 	 */
-	if (!ve_is_super(get_exec_env()) &&
-	    (!mm || mm->vps_dumpable != VD_PTRACE_COREDUMP))
-		return false;
+	if (!ve_is_super(get_exec_env())) {
+		struct ve_struct *ve = task_ve(task);
+
+		if (!mm)
+			return false;
+
+		switch (ve_vps_dumpable(mm, ve)) {
+		case VD_PTRACE_COREDUMP:
+			break;
+		case VD_VE_SETUP_TASK:
+			if (!ve_current_is_pseudosuper(ve))
+				return false;
+			break;
+		default:
+			return false;
+		}
+	}
 
 	if (mm) {
 		if (get_dumpable(mm) == SUID_DUMP_USER)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index ff1c7f9b88c7..1cf4e71e8779 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1778,6 +1778,49 @@ bool ve_check_trusted_exec(struct file *file, struct filename *name)
 	return false;
 }
 
+/**
+ * ve_current_has_mark - is current a task of pseudosuper @ve with @mark
+ * @ve: the VE
+ * @mark: the vps_dumpable value
+ */
+static bool ve_current_has_mark(struct ve_struct *ve, unsigned int mark)
+{
+	struct mm_struct *mm = current->mm;
+
+	return ve->is_pseudosuper && task_ve(current) == ve &&
+	       mm && mm->vps_dumpable == mark;
+}
+
+/**
+ * ve_current_is_pseudosuper - may current use the pseudosuper relaxations of @ve
+ * @ve: the VE that grants them
+ *
+ * Always true for ve0. Otherwise only a VD_VE_SETUP_TASK of @ve may, and only
+ * until pseudosuper is cleared. Exec clears VD_VE_SETUP_TASK, so the container
+ * binaries that the host tools run may not.
+ */
+bool ve_current_is_pseudosuper(struct ve_struct *ve)
+{
+	return ve_is_super(ve) || ve_current_has_mark(ve, VD_VE_SETUP_TASK);
+}
+
+/**
+ * ve_vps_dumpable - vps_dumpable of a task as the access checks see it
+ * @mm: the task's mm
+ * @ve: the task's VE
+ *
+ * A setup task becomes an ordinary one once @ve leaves pseudosuper, which
+ * cannot be set again while @ve runs. ve0 never leaves it.
+ */
+int ve_vps_dumpable(struct mm_struct *mm, struct ve_struct *ve)
+{
+	if (mm->vps_dumpable == VD_VE_SETUP_TASK &&
+	    (ve_is_super(ve) || !ve->is_pseudosuper))
+		return VD_PTRACE_COREDUMP;
+
+	return mm->vps_dumpable;
+}
+
 #ifdef CONFIG_CGROUP_SCHED
 int ve_show_cpu_stat(struct ve_struct *ve, struct seq_file *p)
 {
@@ -1838,14 +1881,17 @@ void ve_setup_task(struct task_struct *task, struct ve_struct *old_ve,
 		return;
 
 	/*
-	 * A task the host sends into a started VE is hidden from the tasks of
-	 * the VE. The mark goes to the mm, which may be shared, so a task
-	 * coming from a container never gets it, unless the container is
-	 * pseudosuper: the host's tasks there cannot be told from its own.
+	 * 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.
 	 */
-	if (task->mm && old_ve != ve && ve->state != VE_STATE_STARTING &&
-	    (ve_is_super(old_ve) || old_ve->is_pseudosuper))
-		task->mm->vps_dumpable = VD_VE_ENTER_TASK;
+	if (task->mm && old_ve != ve &&
+	    (ve_is_super(old_ve) ||
+	     ve_vps_dumpable(task->mm, old_ve) == VD_VE_SETUP_TASK))
+		task->mm->vps_dumpable = ve->state == VE_STATE_STARTING ?
+					 VD_VE_SETUP_TASK : VD_VE_ENTER_TASK;
 
 	/* Drop OOM protection. */
 	task->signal->oom_score_adj = 0;
-- 
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Devel] [PATCH hci-8.2 v2 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
                   ` (2 preceding siblings ...)
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it Mirian Shilakadze
@ 2026-11-17 10:13 ` Mirian Shilakadze
  2026-11-17 10:30   ` no-reply
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries Mirian Shilakadze
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

While a VE is pseudosuper, any task in it may write the read-only files
of the container's root cgroup and sees the hidden cgroup roots. That
includes the container's own binaries that vzctl and CRIU run during
start or restore. quotaon at start can rewrite the root memory.max, and
any of them can write 0 to ve.pseudosuper, which ends the window early
and makes CRIU's restoring tasks reachable again.

Use ve_current_is_pseudosuper() for both, so only setup tasks get them.

Feature: ve: CRIU support
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 kernel/cgroup/cgroup.c | 4 ++--
 kernel/ve/ve.c         | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 77903a56b79e..b0f2e7a24b5f 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4765,7 +4765,7 @@ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf,
 
 	if (!ve_is_super(get_exec_env())
 	    && test_bit(CGRP_VE_ROOT, &cgrp->flags)
-	    && !get_exec_env()->is_pseudosuper
+	    && !ve_current_is_pseudosuper(get_exec_env())
 	    && !(cft->flags & CFTYPE_VE_WRITABLE))
 		return -EPERM;
 
@@ -6947,7 +6947,7 @@ int ve_hide_cgroups(struct cgroup_root *root)
 	 * Hide ve cgroup in CT for docker, still showing it to pseudosuper
 	 * (criu), and also hide non-virtualized cgroups.
 	 */
-	return !ve_is_super(ve) && !ve->is_pseudosuper &&
+	return !ve_is_super(ve) && !ve_current_is_pseudosuper(ve) &&
 	       ((root->subsys_mask & hidden_mask) ||
 		!is_virtualized_cgroot(root));
 }
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 1cf4e71e8779..785d0ed4a05e 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1019,9 +1019,9 @@ static u64 ve_pseudosuper_read(struct cgroup_subsys_state *css, struct cftype *c
  * operations such as mounting cgroups from inside of VE context
  * is allowed in a sake of container restore for example.
  *
- * While dropping pseudosuper privilegues is allowed from
- * any context to set this value up one have to be a real
- * node's owner.
+ * To set this value up one have to be a real node's owner.
+ * Inside the VE only its setup tasks may drop it, see
+ * cgroup_file_write().
  */
 static int ve_pseudosuper_write(struct cgroup_subsys_state *css, struct cftype *cft, u64 val)
 {
-- 
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
                   ` (3 preceding siblings ...)
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks Mirian Shilakadze
@ 2026-11-17 10:13 ` Mirian Shilakadze
  2026-11-17 10:33   ` no-reply
  2026-11-17 11:40   ` Konstantin Khorenko
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks Mirian Shilakadze
  2026-11-17 11:40 ` [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Konstantin Khorenko
  6 siblings, 2 replies; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

While a VE is pseudosuper, any task in it skips the device mount option
filter and the VE mount limit, including the container's own binaries
that vzctl and CRIU run.

Give the option filter relaxation only to setup tasks. The mount limit
also lets through a host task that joined the VE after it started, such
as the CRIU helper that mounts proc for a nested pid namespace during
restore. Without that, restoring such a container near its mount limit
fails. Add ve_current_is_host_task() for the two kinds of host task.

Feature: ve: CRIU support
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 fs/namespace.c     | 12 ++++++------
 include/linux/ve.h |  2 ++
 kernel/ve/ve.c     | 14 ++++++++++++++
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index d622d9b72d32..fd6ef93ed403 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3226,11 +3226,11 @@ int ve_devmnt_process(struct ve_struct *ve, dev_t dev, void **data_pp, int remou
 		if (devmnt->dev == dev) {
 			err = ve_devmnt_check(data, devmnt->allowed_options);
 			/*
-			 * In case of @is_pseudosuper set, ie restore procedure,
-			 * we don't check for allowed options filtering, since
+			 * Setup tasks of a pseudosuper VE, ie the restore
+			 * procedure, skip the allowed options filtering, since
 			 * restore mode is special.
 			 */
-			if (ve->is_pseudosuper)
+			if (ve_current_is_pseudosuper(ve))
 				err = 0;
 
 			if (!err && !remount)
@@ -3255,7 +3255,7 @@ int ve_devmnt_process(struct ve_struct *ve, dev_t dev, void **data_pp, int remou
 			 * the way userspace tool restore container
 			 * it might be nonempty as well.
 			 */
-			if (ve->is_pseudosuper) {
+			if (ve_current_is_pseudosuper(ve)) {
 				err = 0;
 			} else if (((char *)*data_pp)[0] == '\0') {
 				err = 0;
@@ -3330,7 +3330,7 @@ int ve_devmnt_verify(struct ve_struct *ve, dev_t dev, char *opts, bool new_mount
 	bool found = false;
 	int err = 0;
 
-	if (ve->is_pseudosuper)
+	if (ve_current_is_pseudosuper(ve))
 		return 0;
 
 	mutex_lock(&ve->devmnt_mutex);
@@ -3367,7 +3367,7 @@ int ve_devmnt_verify(struct ve_struct *ve, dev_t dev, char *opts, bool new_mount
 
 static inline int ve_try_reserve_mount(struct ve_struct *ve)
 {
-	int ret = ve_is_super(ve) || ve->is_pseudosuper ||
+	int ret = ve_is_super(ve) || ve_current_is_host_task(ve) ||
 		  ve_is_super(get_exec_env());
 	/* Ignore limits in ve0 and pseudosuper cases, but still count. */
 	if (ret)
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 56c310205394..5859550eb07c 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -285,6 +285,7 @@ extern bool is_ve_init_net(const struct net *net);
 void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
 		   struct ve_struct *ve);
 bool ve_current_is_pseudosuper(struct ve_struct *ve);
+bool ve_current_is_host_task(struct ve_struct *ve);
 int ve_vps_dumpable(struct mm_struct *mm, struct ve_struct *ve);
 
 void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool));
@@ -396,6 +397,7 @@ static inline int vz_security_protocol_check(struct net *net, int protocol) { re
 static inline void ve_setup_task(struct task_struct *p, struct ve_struct *old_ve,
 				 struct ve_struct *ve) { }
 static inline bool ve_current_is_pseudosuper(struct ve_struct *ve) { return true; }
+static inline bool ve_current_is_host_task(struct ve_struct *ve) { return true; }
 #define ve_vps_dumpable(mm, ve)	((mm)->vps_dumpable)
 
 static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { }
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 785d0ed4a05e..afa846593a11 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1804,6 +1804,20 @@ bool ve_current_is_pseudosuper(struct ve_struct *ve)
 	return ve_is_super(ve) || ve_current_has_mark(ve, VD_VE_SETUP_TASK);
 }
 
+/**
+ * ve_current_is_host_task - is current a host task of pseudosuper @ve
+ * @ve: the VE
+ *
+ * Always true for ve0. Otherwise true for a setup task of @ve and for a host
+ * task that joined @ve after it started, such as the CRIU helper that mounts
+ * proc for a nested pid namespace, until pseudosuper is cleared.
+ */
+bool ve_current_is_host_task(struct ve_struct *ve)
+{
+	return ve_current_is_pseudosuper(ve) ||
+	       ve_current_has_mark(ve, VD_VE_ENTER_TASK);
+}
+
 /**
  * ve_vps_dumpable - vps_dumpable of a task as the access checks see it
  * @mm: the task's mm
-- 
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
                   ` (4 preceding siblings ...)
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries Mirian Shilakadze
@ 2026-11-17 10:13 ` Mirian Shilakadze
  2026-11-17 10:35   ` no-reply
  2026-11-17 11:40 ` [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Konstantin Khorenko
  6 siblings, 1 reply; 16+ messages in thread
From: Mirian Shilakadze @ 2026-11-17 10:13 UTC (permalink / raw)
  To: khorenko, ptikhomirov; +Cc: devel

While a VE is pseudosuper, any task in it may set NETLINK_REPAIR, set
its CT fields with prctl, write ve.features, ve.failcount, ve.pid_max
and ve.aio_max_nr, and pass the legacy device cgroup check. That
includes the container's own binaries that vzctl and CRIU run.

Use ve_current_is_pseudosuper() for these as well.

Feature: ve: CRIU support
https://virtuozzo.atlassian.net/browse/VSTOR-151265
Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
---
 kernel/sys.c             | 2 +-
 kernel/ve/ve.c           | 8 ++++----
 net/netlink/af_netlink.c | 2 +-
 security/device_cgroup.c | 8 ++++----
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 80f8b9eb17c3..21650d331a42 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2324,7 +2324,7 @@ static int prctl_set_task_ct_fields(struct task_struct *t, unsigned long arg,
 #ifdef CONFIG_VE
 	struct ve_struct *ve __free(put_ve) = get_task_ve(t);
 
-	if (!ve_is_super(ve) && !ve->is_pseudosuper)
+	if (!ve_is_super(ve) && !ve_current_is_pseudosuper(ve))
 		return -EPERM;
 #endif
 
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index afa846593a11..bad7690ce32e 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1066,7 +1066,7 @@ static int ve_features_write(struct cgroup_subsys_state *css, struct cftype *cft
 	struct ve_struct *ve = css_to_ve(css);
 
 	if (!ve_is_super(get_exec_env()) &&
-	    !ve->is_pseudosuper)
+	    !ve_current_is_pseudosuper(ve))
 		return -EPERM;
 
 	down_write(&ve->op_sem);
@@ -1119,7 +1119,7 @@ static ssize_t ve_failcount_write(struct kernfs_open_file *of, char *buf,
 	const struct ve_failcount_entry *entry;
 	atomic_t *fc;
 
-	if (!ve_is_super(get_exec_env()) && !ve->is_pseudosuper)
+	if (!ve_is_super(get_exec_env()) && !ve_current_is_pseudosuper(ve))
 		return -EPERM;
 
 	for (entry = ve_failcounts; entry->name; entry++) {
@@ -1219,7 +1219,7 @@ static int ve_pid_max_write_running_u64(struct cgroup_subsys_state *css,
 	struct nsproxy *ve_nsproxy;
 
 	if (!ve_is_super(get_exec_env()) &&
-	    !ve->is_pseudosuper)
+	    !ve_current_is_pseudosuper(ve))
 		return -EPERM;
 
 	rcu_read_lock();
@@ -1437,7 +1437,7 @@ static int ve_aio_max_nr_write(struct cgroup_subsys_state *css,
 {
 	struct ve_struct *ve = css_to_ve(css);
 
-	if (!ve_is_super(get_exec_env()) && !ve->is_pseudosuper)
+	if (!ve_is_super(get_exec_env()) && !ve_current_is_pseudosuper(ve))
 		return -EPERM;
 
 	down_write(&ve->op_sem);
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f686e6ea30ce..e808d8ae3e1e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1695,7 +1695,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
 #ifdef CONFIG_VE
 		{
 			struct ve_struct *ve = get_exec_env();
-			if (!ve_is_super(ve) && !ve->is_pseudosuper)
+			if (!ve_is_super(ve) && !ve_current_is_pseudosuper(ve))
 				return -ENOPROTOOPT;
 		}
 #endif
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 1629896b2ea1..b0ef5f9380d1 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -923,15 +923,15 @@ static int devcgroup_legacy_check_permission(short type, u32 major, u32 minor,
 
 #ifdef CONFIG_VE
 	/*
-	 * When restoring container allow everything in
-	 * pseudosuper state. We need this for early
-	 * mounting of second ploop device. Still, don't
+	 * When restoring container allow everything to its
+	 * setup tasks in pseudosuper state. We need this for
+	 * early mounting of second ploop device. Still, don't
 	 * change behaviour on the ve0.
 	 */
 	if (!rc) {
 		struct ve_struct *ve = get_exec_env();
 
-		if (!ve_is_super(ve) && ve->is_pseudosuper)
+		if (!ve_is_super(ve) && ve_current_is_pseudosuper(ve))
 			return 0;
 		return -EPERM;
 	}
-- 
2.43.0

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from Mirian Shilakadze
@ 2026-11-17 10:20   ` no-reply
  0 siblings, 0 replies; 16+ messages in thread
From: no-reply @ 2026-11-17 10:20 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko, ptikhomirov; +Cc: devel

> The next changes mark a task entering a VE by where it comes from. Pass
> the VE the task leaves to ve_setup_task(), and call it before the old
> VE namespace is put, as that may drop the last reference to that VE.
> No functional change.
> 
> Feature: ve: ve generic structures
> https://virtuozzo.atlassian.net/browse/VSTOR-151265
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com?part=1


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 2/6] ve: hide only the tasks the host sends into a VE
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 2/6] ve: hide only the tasks the host sends into a VE Mirian Shilakadze
@ 2026-11-17 10:22   ` no-reply
  0 siblings, 0 replies; 16+ messages in thread
From: no-reply @ 2026-11-17 10:22 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko, ptikhomirov; +Cc: devel

> ve_setup_task() marks a task entering a running VE VD_VE_ENTER_TASK,
> which hides it from ptrace and /proc/<pid>/exe inside the VE. A
> container task gets the mark too when it setns()es into its own VE or
> enters a nested one, and a host task entering a stopping or stopped VE
> is not hidden at all.
> 
> The mark says a task is the host's, a later change lets it skip the
> mount limit of a pseudosuper VE, and it goes to the mm, which a
> container task may share with others. So mark only tasks coming from
> the host, in every VE state but starting, which the next change
> handles. A task entering its nested VE is no longer hidden there. In a
> pseudosuper VE the host's tasks cannot be told from the container's
> yet, so a task leaving one is still marked until the next change.
> 
> Feature: trace: prohibit tracing sensitive tasks from CT
> https://virtuozzo.atlassian.net/browse/VSTOR-151265
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com?part=2


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it Mirian Shilakadze
@ 2026-11-17 10:27   ` no-reply
  2026-11-17 11:40   ` Konstantin Khorenko
  1 sibling, 0 replies; 16+ messages in thread
From: no-reply @ 2026-11-17 10:27 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko, ptikhomirov; +Cc: devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ve: stale raw VD_VE_SETUP_TASK mark survives a VE change and
  acts as a setup mark
--

commit e0d51d916ebfeeef972b7b6efe4a3cba6fd46f27
Author: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

ve: hide the tasks that set up a starting VE from the rest of it

The commit marks a task the host sends into a starting VE as VD_VE_SETUP_TASK. While the VE is pseudosuper, such a task dumps no core and is reachable only from other setup tasks of that VE. Once pseudosuper is cleared, the mark counts as VD_PTRACE_COREDUMP.

> diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
> --- a/kernel/ve/ve.c
> +++ b/kernel/ve/ve.c

[ ... ]

> +static bool ve_current_has_mark(struct ve_struct *ve, unsigned int mark)
> +{
> +	struct mm_struct *mm = current->mm;
> +
> +	return ve->is_pseudosuper && task_ve(current) == ve &&
> +	       mm && mm->vps_dumpable == mark;
> +}

[ ... ]

> +	if (task->mm && old_ve != ve &&
> +	    (ve_is_super(old_ve) ||
> +	     ve_vps_dumpable(task->mm, old_ve) == VD_VE_SETUP_TASK))
> +		task->mm->vps_dumpable = ve->state == VE_STATE_STARTING ?
> +					 VD_VE_SETUP_TASK : VD_VE_ENTER_TASK;

[Severity: Low]
Can a stale raw VD_VE_SETUP_TASK mark survive a VE change and be treated as a setup mark again?

ve_setup_task() tests the effective value from ve_vps_dumpable(). Once old_ve has left pseudosuper, that value is VD_PTRACE_COREDUMP, so the condition is false. The raw mm->vps_dumpable is then neither rewritten nor cleared.

Suppose a setup task of VE A stays there after A leaves pseudosuper, and is later moved into a different starting pseudosuper VE B. ve_current_has_mark() and ve_vps_dumpable() read the raw mm->vps_dumpable. The task therefore counts as a setup task of B, with the pseudosuper relaxations and ptrace reachability among B's setup tasks. The commit message says a task coming from a container never gets this.

Would clearing or normalizing the raw mark to VD_PTRACE_COREDUMP when the effective value is no longer VD_VE_SETUP_TASK fix this?

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com?part=3

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks Mirian Shilakadze
@ 2026-11-17 10:30   ` no-reply
  0 siblings, 0 replies; 16+ messages in thread
From: no-reply @ 2026-11-17 10:30 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko, ptikhomirov; +Cc: devel

> While a VE is pseudosuper, any task in it may write the read-only files
> of the container's root cgroup and sees the hidden cgroup roots. That
> includes the container's own binaries that vzctl and CRIU run during
> start or restore. quotaon at start can rewrite the root memory.max, and
> any of them can write 0 to ve.pseudosuper, which ends the window early
> and makes CRIU's restoring tasks reachable again.
> 
> Use ve_current_is_pseudosuper() for both, so only setup tasks get them.
> 
> Feature: ve: CRIU support
> https://virtuozzo.atlassian.net/browse/VSTOR-151265
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com?part=4


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries Mirian Shilakadze
@ 2026-11-17 10:33   ` no-reply
  2026-11-17 11:40   ` Konstantin Khorenko
  1 sibling, 0 replies; 16+ messages in thread
From: no-reply @ 2026-11-17 10:33 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko, ptikhomirov; +Cc: devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ve: stale comment and redundant ve_is_super() in
  ve_try_reserve_mount()
--

commit d4e71dc38fde8afad24f03dceda38eb1041883d9
Author: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

fs: keep the mount relaxations of a pseudosuper VE from container binaries

The commit limits the device mount option filter relaxation to setup tasks of a pseudosuper VE. It limits the VE mount limit relaxation to setup tasks and to host tasks that joined the VE after it started. It adds ve_current_is_host_task() to identify the second kind of task.

> diff --git a/fs/namespace.c b/fs/namespace.c
> index d622d9b72d32..fd6ef93ed403 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c

[ ... ]

> @@ -3367,7 +3367,7 @@ int ve_devmnt_verify(struct ve_struct *ve, dev_t dev, char *opts, bool new_mount
>  
>  static inline int ve_try_reserve_mount(struct ve_struct *ve)
>  {
> -	int ret = ve_is_super(ve) || ve->is_pseudosuper ||
> +	int ret = ve_is_super(ve) || ve_current_is_host_task(ve) ||
>  		  ve_is_super(get_exec_env());
>  	/* Ignore limits in ve0 and pseudosuper cases, but still count. */
>  	if (ret)

[Severity: Low]
This isn't a bug, but the comment below the condition still says limits are ignored in "pseudosuper cases". Now only setup tasks and late-joining host tasks of a pseudosuper VE skip the limit, so the comment describes the old behaviour. Could it be updated?

Also, ve_current_is_host_task() already returns true for ve0 through ve_current_is_pseudosuper(). The leading ve_is_super(ve) term is therefore redundant and can be dropped.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com?part=5

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks Mirian Shilakadze
@ 2026-11-17 10:35   ` no-reply
  0 siblings, 0 replies; 16+ messages in thread
From: no-reply @ 2026-11-17 10:35 UTC (permalink / raw)
  To: Mirian Shilakadze, khorenko, ptikhomirov; +Cc: devel

> While a VE is pseudosuper, any task in it may set NETLINK_REPAIR, set
> its CT fields with prctl, write ve.features, ve.failcount, ve.pid_max
> and ve.aio_max_nr, and pass the legacy device cgroup check. That
> includes the container's own binaries that vzctl and CRIU run.
> 
> Use ve_current_is_pseudosuper() for these as well.
> 
> Feature: ve: CRIU support
> https://virtuozzo.atlassian.net/browse/VSTOR-151265
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261117101329.225854-1-mirian.shilakadze@virtuozzo.com?part=6


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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE
  2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
                   ` (5 preceding siblings ...)
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks Mirian Shilakadze
@ 2026-11-17 11:40 ` Konstantin Khorenko
  6 siblings, 0 replies; 16+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 11:40 UTC (permalink / raw)
  To: Mirian Shilakadze; +Cc: devel

I won't apply this version, please send v3 with the changes below.

On Tue, 17 Nov 2026 14:13:20 +0400, Mirian Shilakadze wrote:
> This series marks the tasks the host sends into a starting VE as setup
> tasks. Fork keeps the mark, exec drops it, and only a task coming from
> the host gets it.

All seven v1 items are done, and the 1/6 reordering of ve_setup_task()
and the namespace put is right. What is left:

1. Patch 3, code: a host task that entered a starting VE and moves on
   to a running VE only after the first one cleared pseudosuper is no
   longer hidden there. ve_vps_dumpable(mm, old_ve) is then
   VD_PTRACE_COREDUMP, so nothing marks the mm, and the root of the
   running VE can read the task's fds. Before the series it got
   VD_VE_ENTER_TASK. Your test hops before the clear. Either close it
   or say in the 3/6 message that this case is not covered and why.

2. Patch 5, code: ve_try_reserve_mount() still checks ve_is_super(ve)
   in front of ve_current_is_host_task(), which is already true for
   ve0, and the comment below still says "pseudosuper cases" (Sashiko
   asked too).

3. Small text fixes: the second paragraph of the 3/6 message has five
   sentences, put the new one about tasks leaving a pseudosuper VE in
   its own; "one have to be" -> "one has to be" in the 4/6 comment;
   "ve0 never leaves it" in the ve_vps_dumpable() kernel-doc reads as
   the opposite of what the code does with ve0.

4. Cover letter change log: "a task that setns()es into its own VE
   keeps its mark" is not new, v1 kept it too.

Thanks.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it Mirian Shilakadze
  2026-11-17 10:27   ` no-reply
@ 2026-11-17 11:40   ` Konstantin Khorenko
  1 sibling, 0 replies; 16+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 11:40 UTC (permalink / raw)
  To: Mirian Shilakadze; +Cc: devel

I won't apply this version, please send v3 with the changes below.

On Tue, 17 Nov 2026 14:13:23 +0400, Mirian Shilakadze wrote:
> +	if (task->mm && old_ve != ve &&
> +	    (ve_is_super(old_ve) ||
> +	     ve_vps_dumpable(task->mm, old_ve) == VD_VE_SETUP_TASK))

Item 1 of the cover letter reply: a setup task that leaves its VE after
the VE cleared pseudosuper is not marked here.

Why: ve_vps_dumpable() reports VD_VE_SETUP_TASK only while old_ve is
pseudosuper. A host task that entered A while it started, stayed there
without exec past the clear and then setns()es into running B keeps a
mark that reads as VD_PTRACE_COREDUMP in B, so B's root can open its
/proc/<pid>/fd. Stock gave it VD_VE_ENTER_TASK.

Item 3 of the cover letter reply: split the five-sentence paragraph of
the message, and fix "ve0 never leaves it" in the kernel-doc.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries
  2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries Mirian Shilakadze
  2026-11-17 10:33   ` no-reply
@ 2026-11-17 11:40   ` Konstantin Khorenko
  1 sibling, 0 replies; 16+ messages in thread
From: Konstantin Khorenko @ 2026-11-17 11:40 UTC (permalink / raw)
  To: Mirian Shilakadze; +Cc: devel

I won't apply this version, please send v3 with the changes below.

On Tue, 17 Nov 2026 14:13:25 +0400, Mirian Shilakadze wrote:
> +	int ret = ve_is_super(ve) || ve_current_is_host_task(ve) ||
>  		  ve_is_super(get_exec_env());
>  	/* Ignore limits in ve0 and pseudosuper cases, but still count. */

Item 2 of the cover letter reply: drop ve_is_super(ve) and update the
comment.

Why: ve_current_is_host_task() returns true for ve0 already, and the
limit is no longer skipped for "pseudosuper cases", only for the host's
tasks.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-11-17 11:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 10:13 [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Mirian Shilakadze
2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from Mirian Shilakadze
2026-11-17 10:20   ` no-reply
2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 2/6] ve: hide only the tasks the host sends into a VE Mirian Shilakadze
2026-11-17 10:22   ` no-reply
2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 3/6] ve: hide the tasks that set up a starting VE from the rest of it Mirian Shilakadze
2026-11-17 10:27   ` no-reply
2026-11-17 11:40   ` Konstantin Khorenko
2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 4/6] cgroup: give the CT root file writes and hidden roots only to setup tasks Mirian Shilakadze
2026-11-17 10:30   ` no-reply
2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 5/6] fs: keep the mount relaxations of a pseudosuper VE from container binaries Mirian Shilakadze
2026-11-17 10:33   ` no-reply
2026-11-17 11:40   ` Konstantin Khorenko
2026-11-17 10:13 ` [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks Mirian Shilakadze
2026-11-17 10:35   ` no-reply
2026-11-17 11:40 ` [Devel] [PATCH hci-8.2 v2 0/6] ve: give the pseudosuper privileges only to the tasks setting up a VE Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox