From: "Guixiong Wei" <weiguixiong@bytedance.com>
To: <x86@kernel.org>
Cc: "Guixiong Wei" <weiguixiong@bytedance.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>,
"Chang S . Bae" <chang.seok.bae@intel.com>,
"Shuah Khan" <shuah@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>, <stable@vger.kernel.org>
Subject: [PATCH v4 0/2] x86/fpu: Fix dynamic fpstate leak on exec()
Date: Mon, 2 Nov 2026 18:08:52 +0800 [thread overview]
Message-ID: <cover.1793604327.git.weiguixiong@bytedance.com> (raw)
An exec() after using an XFD-controlled xfeature leaks the dynamically
allocated fpstate. Fix the cleanup in fpstate_reset() and add an AMX
regression selftest.
The selftest reports FAIL on an unfixed kernel (10/10 FAILs on 7.1.3),
SKIP when vmallocinfo addresses are hidden, and OK with the fix applied.
Changes since v3:
- Close the use-after-free that freeing in fpstate_reset() exposed.
fpu_flush_thread() called fpstate_reset() before
fpu_reset_fpstate_regs() set TIF_NEED_FPU_LOAD, so a context switch
or a kernel FPU user in that window could still see live register
state and save it into the freed buffer. Set TIF_NEED_FPU_LOAD before
the reset and document on fpstate_reset() that callers operating on
the current task must prevent such a save. The race was caught by
the Sashiko review and the fix was suggested by Chang S. Bae.
v3: https://lore.kernel.org/r/cover.1793072271.git.weiguixiong@bytedance.com
v2: https://lore.kernel.org/r/cover.1791428412.git.weiguixiong@bytedance.com
v1: https://lore.kernel.org/r/20260929151013.81562-2-weiguixiong@bytedance.com
Guixiong Wei (2):
x86/fpu: Fix memory leak with dynamic fpstate and exec()
selftests/x86/amx: Test dynamic fpstate cleanup across exec()
arch/x86/kernel/fpu/core.c | 12 ++
tools/testing/selftests/x86/amx.c | 251 +++++++++++++++++++++++++++++-
2 files changed, 261 insertions(+), 2 deletions(-)
base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
--
2.55.0
next reply other threads:[~2026-11-02 10:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 10:08 Guixiong Wei [this message]
2026-11-02 10:10 ` [PATCH v4 1/2] x86/fpu: Fix memory leak with dynamic fpstate and exec() Guixiong Wei
2026-11-02 10:32 ` Guixiong Wei
2026-11-02 10:30 ` [PATCH v4 2/2] selftests/x86/amx: Test dynamic fpstate cleanup across exec() Guixiong Wei
2026-11-06 16:40 ` Chang S. Bae
2026-11-08 13:19 ` Guixiong Wei
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=cover.1793604327.git.weiguixiong@bytedance.com \
--to=weiguixiong@bytedance.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=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.