OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
To: khorenko@virtuozzo.com, ptikhomirov@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks
Date: Tue, 17 Nov 2026 14:13:26 +0400	[thread overview]
Message-ID: <20261117101329.225854-7-mirian.shilakadze@virtuozzo.com> (raw)
In-Reply-To: <20261117101329.225854-1-mirian.shilakadze@virtuozzo.com>

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

  parent reply	other threads:[~2026-11-17 10:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Mirian Shilakadze [this message]
2026-11-17 10:35   ` [Devel] [PATCH hci-8.2 v2 6/6] ve: give the remaining pseudosuper relaxations only to setup tasks 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

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=20261117101329.225854-7-mirian.shilakadze@virtuozzo.com \
    --to=mirian.shilakadze@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@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