[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250813162824.GA15234@redhat.com>
Date: Wed, 13 Aug 2025 18:28:24 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Ingo Molnar <mingo@...nel.org>, "H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>, Jens Axboe <axboe@...nel.dk>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org
Subject: PF_USER_WORKERs and shadow stack
I know nothing about the shadow stacks, perhaps I missed something obvious.
But it seems that if a features_enabled(ARCH_SHSTK_SHSTK) thread creates a
PF_USER_WORKER thread, shstk_alloc_thread_stack() will allocate the shadow
stack for no reason.
Don't we need something like the "patch" below? PF_USER_WORKERs never return
to userspace. Note also that update_fpu_shstk() won't be called in this case.
Oleg.
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -209,9 +209,15 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
* is disabled, new_ssp will remain 0, and fpu_clone() will know not to
* update it.
*/
- new_ssp = shstk_alloc_thread_stack(p, clone_flags, args->stack_size);
- if (IS_ERR_VALUE(new_ssp))
- return PTR_ERR((void *)new_ssp);
+ if (args->fn) {
+ new_ssp = 0;
+ // clear p->thread -> shstk/features,
+ // reset_thread_features() won't work
+ } else {
+ new_ssp = shstk_alloc_thread_stack(p, clone_flags, args->stack_size);
+ if (IS_ERR_VALUE(new_ssp))
+ return PTR_ERR((void *)new_ssp);
+ }
fpu_clone(p, clone_flags, args->fn, new_ssp);
Powered by blists - more mailing lists