mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread()
@ 2026-11-23 13:17 Ömer Mete Kaya
  2026-11-23 15:59 ` Dave Hansen
  0 siblings, 1 reply; 3+ messages in thread
From: Ömer Mete Kaya @ 2026-11-23 13:17 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen
  Cc: x86, hpa, chang.seok.bae, linux-kernel, Ömer Mete Kaya

fpstate_reset() updates the fpstate pointer before resetting its size
and feature metadata without holding fpregs_lock(). If the task is
preempted during this transition, switch_fpu_prepare() can save the FPU
registers using the stale feature configuration into the newly selected,
smaller buffer, potentially causing an out-of-bounds write into the
embedded fpstate buffer.

Hold fpregs_lock() across fpstate_reset() to prevent a context switch
or softirq from accessing the partially updated FPU state.

Closes: https://syzkaller.appspot.com/bug?extid=58cbd7974a103b8b8916
Fixes: e61d6310a0f8 ("x86/fpu: Reset permission and fpstate on exec()")
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
 arch/x86/kernel/fpu/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index d1aeecd57f5e..939f800373a9 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -866,7 +866,9 @@ void fpu__clear_user_states(struct fpu *fpu)
 
 void fpu_flush_thread(void)
 {
+	fpregs_lock();
 	fpstate_reset(x86_task_fpu(current));
+	fpregs_unlock();
 	fpu_reset_fpstate_regs();
 }
 /*
-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread()
  2026-11-23 13:17 [PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread() Ömer Mete Kaya
@ 2026-11-23 15:59 ` Dave Hansen
  2026-11-23 16:52   ` Ömer Mete Kaya
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Hansen @ 2026-11-23 15:59 UTC (permalink / raw)
  To: Ömer Mete Kaya, tglx, mingo, bp, dave.hansen
  Cc: x86, hpa, chang.seok.bae, linux-kernel

On 11/23/26 05:17, Ömer Mete Kaya wrote:
> fpstate_reset() updates the fpstate pointer before resetting its size
> and feature metadata without holding fpregs_lock(). If the task is
> preempted during this transition, switch_fpu_prepare() can save the FPU
> registers using the stale feature configuration into the newly selected,
> smaller buffer, potentially causing an out-of-bounds write into the
> embedded fpstate buffer.
> 
> Hold fpregs_lock() across fpstate_reset() to prevent a context switch
> or softirq from accessing the partially updated FPU state.
> 
> Closes: https://syzkaller.appspot.com/bug?extid=58cbd7974a103b8b8916
> Fixes: e61d6310a0f8 ("x86/fpu: Reset permission and fpstate on exec()")
> Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>

Hi Omer,

I'm genuinely curious how you came across this issue and decided to send
a patch for it.

Did you happen to read the other (brief) conversation on it?

https://lore.kernel.org/lkml/6aff5b8e.4ea6388a.d0c9.0001.GAE@google.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread()
  2026-11-23 15:59 ` Dave Hansen
@ 2026-11-23 16:52   ` Ömer Mete Kaya
  0 siblings, 0 replies; 3+ messages in thread
From: Ömer Mete Kaya @ 2026-11-23 16:52 UTC (permalink / raw)
  To: Dave Hansen, tglx, mingo, bp, dave.hansen
  Cc: x86, hpa, chang.seok.bae, linux-kernel



On 11/23/26 18:59, Dave Hansen wrote:

> Hi Omer,
> 
> I'm genuinely curious how you came across this issue and decided to send
> a patch for it.
> 
> Did you happen to read the other (brief) conversation on it?
> 
> https://lore.kernel.org/lkml/6aff5b8e.4ea6388a.d0c9.0001.GAE@google.com/

Hi Dave,

I saw that on
https://syzkaller.appspot.com/bug?extid=58cbd7974a103b8b8916 and in the
"discussions" section there, the discussion you had with Chang wasn't
visible, so I hadn't read it. Looks like you were already working on it.

Thanks,
Ömer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-23 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 13:17 [PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread() Ömer Mete Kaya
2026-11-23 15:59 ` Dave Hansen
2026-11-23 16:52   ` Ömer Mete Kaya

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®