[Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack
Vasileios Almpanis
vasileios.almpanis at virtuozzo.com
Tue Dec 1 13:20:13 MSK 2026
__kthread_create_on_node_ve() queues a work item from its stack to the
kthreadd worker of the VE. When a fatal signal ends the wait, the
function returns -EINTR and the item stays in the queue. The worker
then uses a dead stack frame. A SIGKILL to the init of a container
during the write of START to ve.state crashes the node:
Oops: general protection fault
RIP: __list_del_entry_valid_or_report
kthread_worker_fn
Comm: kthreadd ve: vek5
Put the work item into struct kthread_create_info. As in the kthreadd
of the host, the caller frees this structure, or, if the caller was
killed, the new thread or the worker on a failed kernel_thread().
https://virtuozzo.atlassian.net/browse/VSTOR-158054
Feature: nfs/nfsd: containerization
Fixes: f94e1c28fdd1 ("ve/kthreadd: add per-ve kthreads creation interface")
Reported-by: Artem Bulgakov <artem.bulgakov at virtuozzo.com>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
---
kernel/kthread.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index a6738c77b09d..baacee7ab331 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -52,6 +52,11 @@ struct kthread_create_info
struct completion *done;
struct list_head list;
+#ifdef CONFIG_VE
+ /* Queued to the VE kthreadd, may outlive a killed caller */
+ struct kthread_work ve_work;
+ unsigned long ve_flags;
+#endif
};
struct kthread {
@@ -508,19 +513,16 @@ static void create_kthread(struct kthread_create_info *create)
}
-struct kthread_create_work {
- struct kthread_work work;
- struct kthread_create_info *info;
- unsigned long flags;
-};
-
+#ifdef CONFIG_VE
static void kthread_create_fn(struct kthread_work *w)
{
- struct kthread_create_work *work = container_of(w,
- struct kthread_create_work, work);
+ struct kthread_create_info *create = container_of(w,
+ struct kthread_create_info, ve_work);
- create_kthread_flags(work->info, work->flags);
+ /* @create must not be touched after kernel_thread() succeeds */
+ create_kthread_flags(create, create->ve_flags);
}
+#endif
static void kthread_create_add(struct kthread_create_info *create)
{
@@ -540,9 +542,6 @@ struct task_struct *__kthread_create_on_node_ve(struct ve_struct *ve,
va_list args)
{
DECLARE_COMPLETION_ONSTACK(done);
- struct kthread_create_work work = {
- KTHREAD_WORK_INIT(work.work, kthread_create_fn),
- };
struct task_struct *task;
struct kthread_create_info *create = kmalloc(sizeof(*create),
GFP_KERNEL);
@@ -562,9 +561,9 @@ struct task_struct *__kthread_create_on_node_ve(struct ve_struct *ve,
#ifdef CONFIG_VE
if (!ve_is_super(ve))
{
- work.info = create;
- work.flags = flags;
- kthread_queue_work(ve->kthreadd_worker, &work.work);
+ kthread_init_work(&create->ve_work, kthread_create_fn);
+ create->ve_flags = flags;
+ kthread_queue_work(ve->kthreadd_worker, &create->ve_work);
} else
#endif
kthread_create_add(create);
---
base-commit: beda1840d22b7707e3f8e18f413afbfffef93d25
change-id: 20261201-ve-kthreadd-stack-3c0f59b5b738
--
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.
More information about the Devel
mailing list