From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: OpenVZ devel list <devel@openvz.org>,
"Denis V. Lunev" <den@virtuozzo.com>
Subject: [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace
Date: Wed, 25 Nov 2026 17:48:01 +0100 [thread overview]
Message-ID: <20261125164802.402895-2-khorenko@virtuozzo.com> (raw)
In-Reply-To: <20261125164802.402895-1-khorenko@virtuozzo.com>
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
The kthreadd of a container is forked from a worker that takes over the
namespaces, root, credentials and cgroups of the task starting the
container, but not its ve namespace, which is not part of nsproxy.
As task_ve follows the ve namespace, kthreadd and every kthread it
forks, khelper included, run as host tasks, and so do the usermode
helpers they start. A core dump to a pipe in a container then fails,
since the host won't execute a file from an untrusted container disk.
Switch the worker into the ve namespace of the starting task as well,
last, as setns() does.
Fixes: 4d033dd01fd3 ("ve: Make task_ve pointer ve namespace based")
https://virtuozzo.atlassian.net/browse/VSTOR-152982
Feature: ve: ve generic structures
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Link: http://lore.virtuozzo.com/20261103173909.2589573-1-eva.kurchatova@virtuozzo.com
ReadyKernel-specific changes:
Patch adjusted to keep line numbers intact: the include takes the place
of a blank line, a blank line in kthread_attach_fn() is dropped and so
is the comment above the switch_ve_namespace() call.
RK_BUG: VSTOR-157027 VSTOR-157031
RK_CHANGELOG: Fix core dumps to a pipe failing in containers.
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
kernel/ve/ve.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 1a87229966042..5e0b643d6dc68 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -33,7 +33,7 @@
#include <linux/tty.h>
#include <linux/device.h>
#include <linux/sched/loadavg.h>
-
+#include <linux/ve_namespace.h>
#include <uapi/linux/vzcalluser.h>
#include <net/rtnetlink.h>
@@ -404,10 +404,10 @@ static void kthread_attach_fn(struct kthread_work *w)
err = commit_creds(cred);
if (err)
goto out;
-
err = cgroup_attach_task_all(target, current);
if (err)
goto out;
+ switch_ve_namespace(current, get_ve_ns(target->ve_ns));
out:
work->result = err;
complete(&work->done);
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-25 16:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 16:48 [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn Konstantin Khorenko
2026-11-25 16:48 ` Konstantin Khorenko [this message]
2026-12-01 0:20 ` [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace no-reply
2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
2026-12-01 0:25 ` no-reply
2026-12-01 0:16 ` [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn no-reply
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=20261125164802.402895-2-khorenko@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=den@virtuozzo.com \
--cc=devel@openvz.org \
--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 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.