From: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: [Devel] [PATCH RHEL10 COMMIT] ve: fix NULL-deref / use-after-free in ve_create() error unwind
Date: Wed, 5 Aug 2026 22:09:41 +0200 [thread overview]
Message-ID: <202608052009.675K9fxR541227@f0.sw.ru> (raw)
In-Reply-To: <20260706110002.1024515-19-khorenko@virtuozzo.com>
The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.2.vz10
------>
commit 7e884677eb9540f3dc2907fd9af753a5ef972a9a
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date: Mon Jul 6 12:59:56 2026 +0200
ve: fix NULL-deref / use-after-free in ve_create() error unwind
ve_create()'s error path ended with:
err_lat:
kmem_cache_free(ve_cachep, ve);
err_ve:
ve_set_state(ve, VE_STATE_STOPPED);
return ERR_PTR(err);
ve_set_state() dereferences ve->state, but at err_ve @ve is either NULL
(the kmem_cache_zalloc() failure jumps straight to err_ve) or already
freed (the err_lat/err_log/err_vdso legs kmem_cache_free() @ve and then
fall through to err_ve) - so every error exit of ve_create() is a NULL
pointer dereference or a use-after-free. It only triggers when an
allocation in ve_create() fails, which is why it stayed latent.
The state assignment is meaningless on the failure path anyway: the css
is never returned to cgroup and the ve is being freed. The success path
already sets ve->state = VE_STATE_STARTING directly. Just drop the bogus
ve_set_state() from the unwind.
Fixes: 8a21e780ce29a ("ve/cgroups: rework is_running into an explicit VE state")
Feature: ve: ve generic structures
https://virtuozzo.atlassian.net/browse/VSTOR-137234
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
kernel/ve/ve.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index d8ef28eedabd0..73d1c3b4873e5 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -802,7 +802,6 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
err_lat:
kmem_cache_free(ve_cachep, ve);
err_ve:
- ve_set_state(ve, VE_STATE_STOPPED);
return ERR_PTR(err);
}
parent reply other threads:[~2026-08-05 20:09 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20260706110002.1024515-19-khorenko@virtuozzo.com>]
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=202608052009.675K9fxR541227@f0.sw.ru \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.