[tip: x86/fpu] x86/fpu: Document reasoning of FX-only fallback
From: tip-bot2 for Andrei Vagin
Date: Fri Sep 25 2026 - 21:12:52 EST
The following commit has been merged into the x86/fpu branch of tip:
Commit-ID: 731300df4f7d7d7153a2aa23b6c4992df3d2a60b
Gitweb: https://git.kernel.org/tip/731300df4f7d7d7153a2aa23b6c4992df3d2a60b
Author: Andrei Vagin <avagin@xxxxxxxxxx>
AuthorDate: Fri, 25 Sep 2026 16:24:50
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Fri, 25 Sep 2026 12:21:14 -07:00
x86/fpu: Document reasoning of FX-only fallback
Add a comment to check_xstate_in_sigframe() to explain the reasoning behind
falling back to the FX-only state when signal frame metadata is
inconsistent.
The fallback is intended to preserve backward compatibility with legacy
user-space processes that are not aware of XSAVE states and might only
fill or copy the legacy FP state.
However, this fallback should be avoided whenever possible. If a process
was actively using extended features, falling back to the FX-only state
silently resets those extended registers to their initial state, which
can lead to silent user-space state corruption.
Signed-off-by: Andrei Vagin <avagin@xxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Alexander Mikhalitsyn <alexander@xxxxxxxxxxxxx>
Reviewed-by: Chang S. Bae <chang.seok.bae@xxxxxxxxx>
Link: https://patch.msgid.link/20260925162454.1403405-5-avagin@xxxxxxxxxx
---
arch/x86/kernel/fpu/signal.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index b9dcd0c..d56819f 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -54,6 +54,14 @@ static inline bool check_xstate_in_sigframe(struct fxregs_state __user *buf_fx,
if (likely(magic2 == FP_XSTATE_MAGIC2))
return true;
err_setfx:
+ /*
+ * The fallback to FX-only state is used to preserve backward
+ * compatibility with user-space processes that are not aware of xsave
+ * states.
+ *
+ * In all other cases, returning false (to trigger SIGSEGV) is
+ * preferred to avoid silent user-space state corruption.
+ */
trace_x86_fpu_xstate_check_failed(x86_task_fpu(current));
/* Set the parameters for fx only state */