[PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread()
From: Ömer Mete Kaya
Date: Mon Nov 23 2026 - 08:19:02 EST
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@xxxxxxxxx>
---
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