From: "Denis V. Lunev" <den@openvz.org>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v2 2/3] ve: free ve_name together with the ve, not at cgroup offline
Date: Mon, 16 Nov 2026 14:44:44 +0100 [thread overview]
Message-ID: <20261116134445.438480-3-den@openvz.org> (raw)
In-Reply-To: <20261116134445.438480-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
ve_offline() frees ve->ve_name as soon as the ve cgroup goes offline,
while the ve itself lives on as long as anything holds a reference, a
ve namespace for one. Tasks of that namespace still point at the ve,
and readers of another task's ve name, such as sched_show_task(),
dereference the string with nothing that keeps it from being freed
under them. A reference to the ve does not help either, as it does not
hold the cgroup online.
Free the name in ve_destroy() instead. That is css_free, which runs
after an RCU grace period, so the name is valid for as long as the ve
is and an RCU reader of task_ve() can print it. ve0 is never destroyed
and keeps its static name. ve_offline() is left empty and goes away.
https://virtuozzo.atlassian.net/browse/VSTOR-155341
Feature: ve: ve generic structures
Suggested-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
kernel/ve/ve.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 6cdfaaa4e703..cdfd03416b39 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -894,16 +894,6 @@ static int ve_online(struct cgroup_subsys_state *css)
return 0;
}
-static void ve_offline(struct cgroup_subsys_state *css)
-{
- struct ve_struct *ve = css_to_ve(css);
-
- if (!ve_is_super(ve)) {
- kfree(ve->ve_name);
- ve->ve_name = NULL;
- }
-}
-
static void ve_devmnt_free(struct ve_devmnt *devmnt)
{
if (!devmnt)
@@ -939,6 +929,7 @@ static void ve_destroy(struct cgroup_subsys_state *css)
ve_free_vdso(ve);
mntput(ve->devtmpfs_mnt);
free_percpu(ve->sched_lat_ve.cur);
+ kfree(ve->ve_name);
ve_set_state(ve, VE_STATE_DEAD);
kmem_cache_free(ve_cachep, ve);
}
@@ -1690,7 +1681,6 @@ static struct cftype ve_cftypes[] = {
struct cgroup_subsys ve_cgrp_subsys = {
.css_alloc = ve_create,
.css_online = ve_online,
- .css_offline = ve_offline,
.css_free = ve_destroy,
.legacy_cftypes = ve_cftypes,
.dfl_cftypes = ve_cftypes,
--
2.55.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-16 13:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 13:44 [Devel] [PATCH hci-8.1 v2 0/3] sched: fix hard lockups on task_lock taken under scheduler and diagnostic locks Denis V. Lunev
2026-11-16 13:44 ` [Devel] [PATCH hci-8.1 v2 1/3] sched/stats: fix a hard lockup on task_lock in update_sched_lat() Denis V. Lunev
2026-11-16 13:50 ` no-reply
2026-11-16 16:31 ` Konstantin Khorenko
2026-11-16 13:44 ` Denis V. Lunev [this message]
2026-11-16 13:49 ` [Devel] [PATCH hci-8.1 v2 2/3] ve: free ve_name together with the ve, not at cgroup offline no-reply
2026-11-16 16:31 ` Konstantin Khorenko
2026-11-16 13:44 ` [Devel] [PATCH hci-8.1 v2 3/3] sched: drop task_lock from sched_show_task() Denis V. Lunev
2026-11-16 13:52 ` no-reply
2026-11-16 16:31 ` Konstantin Khorenko
2026-11-16 16:03 ` [Devel] [PATCH hci-8.1 v2 0/3] sched: fix hard lockups on task_lock taken under scheduler and diagnostic locks Vasileios Almpanis
2026-11-16 16:31 ` Konstantin Khorenko
2026-11-16 16:31 ` 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=20261116134445.438480-3-den@openvz.org \
--to=den@openvz.org \
--cc=devel@openvz.org \
--cc=khorenko@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