[Linux Kernel Bug] WARNING in get_xsave_addr

From: Jiaming Zhang

Date: Sat Dec 05 2026 - 22:58:41 EST


Hi Linux kernel developers and maintainers,

We are writing to report a warning issue in the x86 FPU and shadow stack
subsystem, reproducible on the latest version of Linux (v7.4-rc5, commit
fe6ff8d5d675).

On a CPU or VM guest supporting SHSTK and XSAVES without enumerating
the user CET XSAVE state bit, an unprivileged 64-bit process triggers
the warning by enabling user shadow stacks via arch_prctl() and dumping
core. Below is the kernel report:

!xfeature_enabled(xfeature_nr)
WARNING: arch/x86/kernel/fpu/xstate.c:1060 at
get_xsave_addr+0x132/0x1b0 arch/x86/kernel/fpu/xstate.c:1060, CPU#0:
repro.out/9436
Modules linked in:
CPU: 0 UID: 0 PID: 9436 Comm: repro.out Not tainted 7.4.0-rc5 #62 PREEMPT(full)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix,
1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:get_xsave_addr+0x132/0x1b0 arch/x86/kernel/fpu/xstate.c:1060
Call Trace:
<TASK>
ssp_get+0x110/0x1c0 arch/x86/kernel/fpu/regset.c:198
__regset_get kernel/regset.c:23 [inline]
regset_get_alloc+0x106/0x1c0 kernel/regset.c:48
fill_thread_core_info fs/binfmt_elf.c:1757 [inline]
fill_note_info fs/binfmt_elf.c:1892 [inline]
elf_core_dump+0x10b8/0x3ac0 fs/binfmt_elf.c:2020
coredump_write fs/coredump.c:1150 [inline]
do_coredump+0x54cb/0x6020 fs/coredump.c:1237
vfs_coredump+0x9a5/0xfb0 fs/coredump.c:1312
get_signal+0x1145/0x1460 kernel/signal.c:3098
arch_do_signal_or_restart+0x9a/0x7a0 arch/x86/kernel/signal.c:337
__exit_to_user_mode_loop kernel/entry/common.c:66 [inline]
exit_to_user_mode_loop kernel/entry/common.c:101 [inline]
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
irqentry_exit_to_user_mode_prepare
include/linux/irq-entry-common.h:244 [inline]
irqentry_exit_to_user_mode include/linux/irq-entry-common.h:315 [inline]
irqentry_exit+0x34f/0xa20 kernel/entry/common.c:152
asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
</TASK>

Following is the root cause analysis for this issue. Note that the
analysis was performed with the assistance of an LLM, and we have tried
our best to ensure its accuracy.

The warning triggers in get_xsave_addr() because ssp_get() asks to read
the user shadow-stack state (XFEATURE_CET_USER) from a task's FPU save
buffer during an ELF core dump, even though the kernel never enabled
XFEATURE_CET_USER in its active XSAVE feature mask.

On x86-64, user shadow stacks keep their configuration and stack pointer
in supervisor registers that Linux saves and restores across context
switches via XSAVES under XFEATURE_CET_USER. During boot, however, CPU
feature detection runs before XSAVE state initialization.

Since commit 0dc2a76092d9 ("x86/cpufeatures: Enable CET CR4 bit for
shadow stack"), setup_cet() enables X86_FEATURE_USER_SHSTK when
CONFIG_X86_USER_SHADOW_STACK is enabled and the CPU supports SHSTK and
XSAVES, before fpu__init_system_xstate() reads XSAVE features via CPUID.

When fpu__init_system_xstate() later inspects that mask, it disables AVX
and AVX-512 if their XSAVE bits are absent, yet leaves SHSTK enabled
when XFEATURE_CET_USER is missing. Also, cpuid_deps lacks a dependency
from X86_FEATURE_USER_SHSTK to SHSTK when SHSTK or XSAVE is cleared.

As a result, arch_prctl() lets unprivileged 64-bit tasks enable live
shadow-stack registers that XSAVES never saves or restores across
context switches. When such a task dumps core, clones a thread, or is
inspected via ptrace(), reading XFEATURE_CET_USER triggers the warning.

To fix this issue, we can record X86_FEATURE_USER_SHSTK's dependency on
X86_FEATURE_SHSTK in cpuid_deps and clear X86_FEATURE_SHSTK in
fpu__init_system_xstate() when XFEATURE_MASK_CET_USER is missing from
the CPU's XSAVE features, matching the existing AVX and AVX-512 checks:

diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index acbcec394ef1..a1a7b2c1b2f0 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -89,6 +89,7 @@ static const struct cpuid_dep cpuid_deps[] = {
{ X86_FEATURE_AMX_BF16, X86_FEATURE_AMX_TILE },
{ X86_FEATURE_AMX_INT8, X86_FEATURE_AMX_TILE },
{ X86_FEATURE_SHSTK, X86_FEATURE_XSAVES },
+ { X86_FEATURE_USER_SHSTK, X86_FEATURE_SHSTK },
{ X86_FEATURE_FRED, X86_FEATURE_LKGS },
{ X86_FEATURE_SPEC_CTRL_SSBD, X86_FEATURE_SPEC_CTRL },
{ X86_FEATURE_LASS, X86_FEATURE_SMAP },
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index da303714379c..472b13e52098 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -861,6 +861,14 @@ void __init fpu__init_system_xstate(unsigned int
legacy_size)
}
}

+ if (boot_cpu_has(X86_FEATURE_SHSTK)) {
+ if (!(fpu_kernel_cfg.max_features & XFEATURE_MASK_CET_USER)) {
+ pr_err(FW_BUG
+ "x86/fpu: Disabling shadow stack support due to missing xstate
features\n");
+ setup_clear_cpu_cap(X86_FEATURE_SHSTK);
+ }
+ }
+
if (fpu_kernel_cfg.max_features & XFEATURE_MASK_APX &&
fpu_kernel_cfg.max_features & (XFEATURE_MASK_BNDREGS |
XFEATURE_MASK_BNDCSR)) {
/*

The kernel console output, kernel config, and C reproducer are available
on Google Drive:
https://drive.google.com/drive/folders/1dBdi4H5wl_2-DoykFJG2zGKzquv2rABk?usp=drive_link

Best regards,
Jiaming Zhang