[Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Nov 25 19:48:01 MSK 2026
From: Eva Kurchatova <eva.kurchatova at 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 at virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov at 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 at 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
More information about the Devel
mailing list