public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Andrei Vagin <avagin@google.com>,
	Thomas Gleixner <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>, <criu@lists.linux.dev>,
	<x86@kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] Revert "x86/fpu: Refine and simplify the magic number check during signal return"
Date: Wed, 29 Apr 2026 00:26:51 -0700	[thread overview]
Message-ID: <7c2681ee-a53c-402c-8947-e7a74f8720c8@intel.com> (raw)
In-Reply-To: <20260429000623.3356606-1-avagin@google.com>

On 4/28/2026 5:06 PM, Andrei Vagin wrote:
> 
> The reverted commit broke applications that construct signal frames in
> userspace (such as CRIU and gVisor) if the frame's xstate size is
> smaller than the kernel's fpstate->user_size.

In the extended state area, the sigframe embeds the hardware-defined 
XSAVE format. If CPU A and CPU B support different XSTATE features, the 
layout (size and offsets) differ across systems. However, within a 
system, the layout is invariant. Userspace can query CPUID to obtain the 
exact offset and sizes, which effectively defines the ABI.

On top of the XSAVE data, the kernel appends metadata (e.g. the xstate 
size and magic values). In particular fpstate->user_size is written by 
save_sw_bytes() at signal delivery. On sigreturn, the kernel validates 
this, which is a symmetric and straightforward check.

Because the format is hardware-defined, arbitrary size mismatches should 
not be allowed. The sigframe should match the CPU-defined XSAVE layout. 
So the change in fact strengthens the sanity check.

> Furthermore, this introduces a critical issue for checkpoint/restore
> tools like CRIU. If a process is checkpointed while inside a signal
> handler, its stack contains a signal frame formatted according to the
> source host's xstate capabilities.  If that process is later restored on
> a destination host with larger xstate capabilities (e.g., a newer CPU
> with more features enabled, resulting in a larger fpstate->user_size),
> the kernel will look for FP_XSTATE_MAGIC2 at the destination host's
> larger user_size offset instead of the offset encoded in the frame's
> fx_sw->xstate_size.  This causes the magic2 check to fail, forcing
> sigreturn to silently fall back to "FX-only" mode.

It seems that userspace could translate the XSAVE buffer from CPU A's 
format to CPU B's format during restore. If so, the frame can be 
consistent with the destination system without modifying 
fx_sw->xstate_size, and the kernel-side validation would continue to 
work as intended.

Thanks,
Chang

  reply	other threads:[~2026-04-29  7:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29  0:06 [PATCH] Revert "x86/fpu: Refine and simplify the magic number check during signal return" Andrei Vagin
2026-04-29  7:26 ` Chang S. Bae [this message]
2026-04-29 16:44   ` Andrei Vagin
2026-04-29 17:15     ` Chang S. Bae
2026-04-29 20:44       ` Andrei Vagin
2026-04-29 21:44         ` Chang S. Bae
2026-04-30  0:28           ` Andrei Vagin
2026-05-01 18:44   ` Andrei Vagin
2026-05-01 19:13     ` Chang S. Bae
2026-05-01 20:50       ` Andrei Vagin
2026-05-01 21:04         ` Chang S. Bae
2026-05-01 21:42           ` Andrei Vagin
2026-05-02 19:23             ` Chang S. Bae

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=7c2681ee-a53c-402c-8947-e7a74f8720c8@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=avagin@google.com \
    --cc=bp@alien8.de \
    --cc=criu@lists.linux.dev \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox