From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "oleg@redhat.com" <oleg@redhat.com>
Cc: "debug@rivosinc.com" <debug@rivosinc.com>,
"mingo@kernel.org" <mingo@kernel.org>,
"bp@alien8.de" <bp@alien8.de>,
"broonie@kernel.org" <broonie@kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"Mehta, Sohil" <sohil.mehta@intel.com>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH 5/6] x86/shstk: don't create the shadow stack for PF_USER_WORKERs
Date: Fri, 15 Aug 2025 17:46:13 +0000 [thread overview]
Message-ID: <e802f42ac5d6cf4f5ac5e5693357efa67b2af85e.camel@intel.com> (raw)
In-Reply-To: <20250815165445.GJ11549@redhat.com>
On Fri, 2025-08-15 at 18:54 +0200, Oleg Nesterov wrote:
> > So what are we trying to do for PF_USER_WORKER? Prevent them from wasting a
> > VMA
> > with an unused shadow stack? Or set PF_USER_WORKER's aside from the logic
> > that
> > is about more than protecting the individual thread in the process?
>
> Let me quote my answer to Mark:
>
> The fact that a kernel thread can have the pointless ARCH_SHSTK_SHSTK
> is
> the only reason I know why x86_task_fpu(PF_USER_WORKER) has to work.
Maybe you can explain the exact failure mode here? ARCH_SHSTK_SHSTK isn't part
of the FPU infrastructure, so maybe you can explain how there is some cascade.
>
> I'd like to make this logic consistent with PF_KTHREAD, and in the
> longer
> term change the x86 FPU code so that the kernel threads can run
> without
> without "struct fpu" attached to task_struct.
For PF_USER_WORKER it still has access to the user MM, right? Shouldn't it
inherit PKRU from the parent?
Stop me if I'm telling you something you already know... For better or worse,
the x86 FPU state has grown from the classic "extra math registers", to include
other things like PKRU and supervisor state. Supervisor state controls other
thread specific state that *only* the kernel is supposed to have complete access
to. Some of the xfeatures are even about saving and restoring state that *only*
affects the kernel. So I think each xfeature needs to be evaluated, and they are
all annoyingly different. I think LBR works in the kernel too?
>
> And again, please see
>
> Warning from x86_task_fpu()
> https://lore.kernel.org/all/aJVuZZgYjEMxiUYq@ly-workstation/
>
> PF_USER_WORKERs and shadow stack
> https://lore.kernel.org/all/20250813162824.GA15234@redhat.com/
>
> and 6/6 in this series.
I kind of think it would be more appropriate for you to explain more about what
you are trying to do. I've read three things:
- Prevent wasting a shstk VMA (which Dave suggested maybe wasn't worth it)
- Prevent issue around update_fpu_shstk(), which I'm not sure is an issue
- Prevent ptrace from setting FPU state on user workers because it caused
problems (details unclear), by changing the FPU design in a way that apparently
has impacts across FPU-using features (unclear why this is the best way to
prevent it)
TBH, based on my current understanding, all three sound dubious to me. Let's get
on the same page as far as the goals before we discuss shstk changes further.
You might be aware that the x86 FPU is seen as too complex already and so adding
special cases tends to have a high bar. So consider making a strong, clear
justification for the overall problem/solution you have in mind.
next prev parent reply other threads:[~2025-08-15 17:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 10:13 [PATCH 0/6] x86/fpu: don't abuse x86_task_fpu(PF_USER_WORKER) in .regset_get() paths Oleg Nesterov
2025-08-14 10:14 ` [PATCH 1/6] x86/fpu: change copy_xstate_to_uabi_buf() to accept fpstate + pkru instead of task_struct Oleg Nesterov
2025-08-14 16:46 ` Edgecombe, Rick P
2025-08-15 12:22 ` Oleg Nesterov
2025-08-14 10:14 ` [PATCH 2/6] x86/fpu: regset: introduce get_fpstate() helper Oleg Nesterov
2025-08-14 10:14 ` [PATCH 3/6] x86/fpu: fold sync_fpstate() into get_fpstate() Oleg Nesterov
2025-08-14 10:14 ` [PATCH 4/6] x86/shstk: add "task_struct *tsk" argument to reset_thread_features() Oleg Nesterov
2025-08-14 10:14 ` [PATCH 5/6] x86/shstk: don't create the shadow stack for PF_USER_WORKERs Oleg Nesterov
2025-08-14 17:03 ` Edgecombe, Rick P
2025-08-14 18:33 ` Mark Brown
2025-08-14 22:43 ` Edgecombe, Rick P
2025-08-15 11:44 ` Mark Brown
2025-08-15 19:11 ` Deepak Gupta
2025-08-18 17:27 ` Mark Brown
2025-08-19 17:41 ` Deepak Gupta
2025-08-15 13:01 ` Oleg Nesterov
2025-08-15 13:08 ` Oleg Nesterov
2025-08-15 15:28 ` Mark Brown
2025-08-15 15:43 ` Oleg Nesterov
2025-08-15 15:48 ` Mark Brown
2025-08-15 16:00 ` Oleg Nesterov
2025-08-15 17:08 ` Mark Brown
2025-08-15 12:17 ` Oleg Nesterov
2025-08-15 16:19 ` Edgecombe, Rick P
2025-08-15 16:54 ` Oleg Nesterov
2025-08-15 17:46 ` Edgecombe, Rick P [this message]
2025-08-15 19:13 ` Oleg Nesterov
2025-08-14 10:14 ` [PATCH 6/6] x86/fpu: change get_fpstate() to return &init_fpstate if PF_USER_WORKER Oleg Nesterov
2025-08-15 15:52 ` [PATCH 0/6] x86/fpu: don't abuse x86_task_fpu(PF_USER_WORKER) in .regset_get() paths Oleg Nesterov
2025-08-15 15:59 ` Dave Hansen
2025-08-15 16:02 ` Oleg Nesterov
2025-08-15 16:32 ` Sohil Mehta
2025-08-15 19:33 ` Oleg Nesterov
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=e802f42ac5d6cf4f5ac5e5693357efa67b2af85e.camel@intel.com \
--to=rick.p.edgecombe@intel.com \
--cc=axboe@kernel.dk \
--cc=bp@alien8.de \
--cc=broonie@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=debug@rivosinc.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=sohil.mehta@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®