From: Ingo Molnar <mingo@kernel.org>
To: Andrei Vagin <avagin@google.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
"Chang S. Bae" <chang.seok.bae@intel.com>,
linux-kernel@vger.kernel.org, criu@lists.linux.dev,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 3/4] x86/fpu: Add consistency check between xstate_size and xfeatures
Date: Fri, 5 Jun 2026 11:50:39 +0200 [thread overview]
Message-ID: <aiKb73J0nq3_L5kH@gmail.com> (raw)
In-Reply-To: <20260604165604.1195243-4-avagin@google.com>
* Andrei Vagin <avagin@google.com> wrote:
> The signal frame is designed to be self-describing, where xstate_size
> indicates the actual size of the xstate context. The kernel previously
> lacked a check to ensure that the provided xstate_size was sufficient
> for the features enabled in the xfeatures mask. Additionally,
> restore_fpregs_from_user() always used the default xstate_size to fault
> in the xstate user buffer.
>
> These consistency checks have been added:
> * Validate that xfeatures is a subset of the features enabled for the
> task.
> * Calculate the required size for the validated xfeatures mask.
> * Ensure the provided xstate_size is sufficient.
>
> These checks prevent the kernel from attempting to fault in memory past
> the end of a frame.
>
> Signed-off-by: Andrei Vagin <avagin@google.com>
> ---
> arch/x86/kernel/fpu/signal.c | 29 +++++++++++++++++++++++------
> arch/x86/kernel/fpu/xstate.c | 2 +-
> arch/x86/kernel/fpu/xstate.h | 2 ++
> 3 files changed, 26 insertions(+), 7 deletions(-)
So since this is a potentially invasive change, could you please split
it up into further incremental steps, with the behavioral changes at
the end:
x86/fpu: Export xstate_calculate_size() internally
x86/fpu: Extend restore_fpregs_from_user() with 'xstate_size'
x86/fpu: Rename 'fpstate' to 'sig_fpstate' in check_xstate_in_sigframe()
x86/fpu: Introduce 'fpstate' helper variable in check_xstate_in_sigframe()
etc.
To make it all more reviewable & bisectable.
Also, could the check_xstate_in_sigframe() function get some TLC before
we modify it materially:
1)
arch/x86/kernel/fpu/signal.c:static inline bool check_xstate_in_sigframe(struct fxregs_state __user *fxbuf,
arch/x86/kernel/fpu/signal.c: if (!check_xstate_in_sigframe(buf_fx, &fx_sw_user))
Please harmonize the argument names: why is it 'buf_fx' in one
function and 'fxbuf' in another? We should probably standardize
on 'buf_fx' everywhere.
2)
Why is an error condition label called 'setfx'? How about
'error_setfx' or so. Makes patches more straightforward to read.
etc., I'm sure there's more.
Plus regarding the behavioral changes, this one should probably
be its own patch as well:
+ /* Enforce XFEATURE_MASK_FPSSE when XSAVE is enabled */
+ fx_sw->xfeatures |= XFEATURE_MASK_FPSSE;
With the new size checks in another patch, right?
Thanks,
Ingo
next prev parent reply other threads:[~2026-06-05 9:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 16:56 [PATCH v2 0/4] x86/fpu: Restore and reinforce signal frame portability Andrei Vagin
2026-06-04 16:56 ` [PATCH 1/4] x86/fpu: Document " Andrei Vagin
2026-06-04 22:32 ` Andrei Vagin
2026-06-04 16:56 ` [PATCH 2/4] selftests/x86: Add a test for " Andrei Vagin
2026-06-04 16:56 ` [PATCH 3/4] x86/fpu: Add consistency check between xstate_size and xfeatures Andrei Vagin
2026-06-05 9:50 ` Ingo Molnar [this message]
2026-06-04 16:56 ` [PATCH 4/4] selftests/x86: Add a consistency test for signal frames Andrei Vagin
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=aiKb73J0nq3_L5kH@gmail.com \
--to=mingo@kernel.org \
--cc=avagin@google.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=criu@lists.linux.dev \
--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 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.