From: "Ömer Mete Kaya" <omermetekaya0@gmail.com>
To: tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com
Cc: x86@kernel.org, hpa@zytor.com, chang.seok.bae@intel.com,
linux-kernel@vger.kernel.org,
"Ömer Mete Kaya" <omermetekaya0@gmail.com>
Subject: [PATCH] x86/fpu: hold fpregs_lock() across fpstate_reset() in fpu_flush_thread()
Date: Mon, 23 Nov 2026 16:17:59 +0300 [thread overview]
Message-ID: <20261123131836.220685-1-omermetekaya0@gmail.com> (raw)
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
next reply other threads:[~2026-11-23 13:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 13:17 Ömer Mete Kaya [this message]
2026-11-23 15:59 ` Dave Hansen
2026-11-23 16:52 ` Ömer Mete Kaya
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=20261123131836.220685-1-omermetekaya0@gmail.com \
--to=omermetekaya0@gmail.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--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®