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 1/6] ve: tell ve_setup_task() which VE the task comes from
Date: Tue, 17 Nov 2026 14:13:21 +0400 [thread overview]
Message-ID: <20261117101329.225854-2-mirian.shilakadze@virtuozzo.com> (raw)
In-Reply-To: <20261117101329.225854-1-mirian.shilakadze@virtuozzo.com>
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
next prev 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 ` Mirian Shilakadze [this message]
2026-11-17 10:20 ` [Devel] [PATCH hci-8.2 v2 1/6] ve: tell ve_setup_task() which VE the task comes from 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
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-2-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