* [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack
@ 2026-12-01 10:20 Vasileios Almpanis
2026-12-01 10:24 ` no-reply
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Vasileios Almpanis @ 2026-12-01 10:20 UTC (permalink / raw)
To: Pavel Tikhomirov, Mirian Shilakadze, Konstantin Khorenko
Cc: devel, Artem Bulgakov
__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@virtuozzo.com>
Signed-off-by: Vasileios Almpanis <vasileios.almpanis@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.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack
2026-12-01 10:20 [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack Vasileios Almpanis
@ 2026-12-01 10:24 ` no-reply
2026-12-01 10:52 ` Mirian Shilakadze
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: no-reply @ 2026-12-01 10:24 UTC (permalink / raw)
To: Vasileios Almpanis, Pavel Tikhomirov, Mirian Shilakadze,
Konstantin Khorenko
Cc: devel, Artem Bulgakov
> __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@virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261201-ve-kthreadd-stack-v1-1-b4fb15511033@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack
2026-12-01 10:20 [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack Vasileios Almpanis
2026-12-01 10:24 ` no-reply
@ 2026-12-01 10:52 ` Mirian Shilakadze
2026-12-01 15:17 ` Konstantin Khorenko
2026-12-01 15:17 ` Konstantin Khorenko
3 siblings, 0 replies; 5+ messages in thread
From: Mirian Shilakadze @ 2026-12-01 10:52 UTC (permalink / raw)
To: Vasileios Almpanis, Pavel Tikhomirov, Konstantin Khorenko
Cc: devel, Artem Bulgakov
On 12/1/26 2:20 PM, Vasileios Almpanis wrote:
> __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@virtuozzo.com>
> Signed-off-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Reviewed-by: Mirian Shilakadze <mirian.shilakadze@virtuozzo.com>
--
Best regards, Mirian Shilakadze
Linux C Virtualization Developer, Virtuozzo.
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack
2026-12-01 10:20 [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack Vasileios Almpanis
2026-12-01 10:24 ` no-reply
2026-12-01 10:52 ` Mirian Shilakadze
@ 2026-12-01 15:17 ` Konstantin Khorenko
2026-12-01 15:17 ` Konstantin Khorenko
3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Khorenko @ 2026-12-01 15:17 UTC (permalink / raw)
To: Vasileios Almpanis; +Cc: devel, Artem Bulgakov
Applying with these fixes on my side:
- Fixes: moved above the Jira URL, as in the vz commit template
On Tue, 01 Dec 2026 10:20:13 +0000, Vasileios Almpanis wrote:
> https://virtuozzo.atlassian.net/browse/VSTOR-158054
>
> Feature: nfs/nfsd: containerization
> Fixes: f94e1c28fdd1 ("ve/kthreadd: add per-ve kthreads creation interface")
The fix is right: the request now lives as long as the host kthreadd
keeps its own, and whoever takes create->done frees it.
Separate patches, not needed for this patch. The task already covers
it, as R-3 and R-1:
1. __kthread_create_on_node_ve() is not serialised against
ve_stop_kthreadd(). svc_start_kthreads() queues from a container
task under nfsd_mutex only, and zap_pid_ns_processes() calls
ve_stop_ns() before it kills the other tasks of the container. A
request queued after the flush never runs, and a later one goes to
a freed or NULL worker.
https://virtuozzo.atlassian.net/browse/VSTOR-158054
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack
2026-12-01 10:20 [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack Vasileios Almpanis
` (2 preceding siblings ...)
2026-12-01 15:17 ` Konstantin Khorenko
@ 2026-12-01 15:17 ` Konstantin Khorenko
3 siblings, 0 replies; 5+ messages in thread
From: Konstantin Khorenko @ 2026-12-01 15:17 UTC (permalink / raw)
To: Pavel Tikhomirov, Mirian Shilakadze, Vasileios Almpanis
Cc: devel, Artem Bulgakov
On Tue, 01 Dec 2026 10:20:13 +0000, Vasileios Almpanis wrote:
> ve/kthreadd: keep the create request of a VE kthread off the stack
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.26.7.vz10, thanks!
[1/1] ve/kthreadd: keep the create request of a VE kthread off the stack
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/208be5001df4
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-01 15:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 10:20 [Devel] [PATCH hci-8.2] ve/kthreadd: keep the create request of a VE kthread off the stack Vasileios Almpanis
2026-12-01 10:24 ` no-reply
2026-12-01 10:52 ` Mirian Shilakadze
2026-12-01 15:17 ` Konstantin Khorenko
2026-12-01 15:17 ` Konstantin Khorenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox