All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Daniel Wade <danjwade95@gmail.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>
Cc: "H . Peter Anvin" <hpa@zytor.com>,
	Andrei Vagin <avagin@google.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/fpu: Put non-enabled dynamic features into init state on sigreturn
Date: Sat, 21 Nov 2026 14:08:21 -0800	[thread overview]
Message-ID: <188d736e-8d8b-449b-8826-d6ff72800379@intel.com> (raw)
In-Reply-To: <20261117112640.1435-1-danjwade95@gmail.com>

On 11/17/2026 3:26 AM, Daniel Wade wrote:
> 
> diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
> index 164255d..757a831 100644
> --- a/arch/x86/kernel/fpu/signal.c
> +++ b/arch/x86/kernel/fpu/signal.c
> @@ -267,6 +267,11 @@ static int __restore_fpregs_from_user(void __user *buf, u64 task_xfeatures,
>   		/* Restore enabled features only. */
>   		xrestore_mask &= task_xfeatures;
>   		init_bv = task_xfeatures & ~xrestore_mask;
> +
> +		/* The previous task's state can linger in disabled features. */
> +		if (test_thread_flag(TIF_NEED_FPU_LOAD))
> +			init_bv |= fpu_user_cfg.max_features & ~task_xfeatures;
> +
>   		if (likely(!fx_only))
>   			ret = xrstor_from_user_sigframe(buf, xrestore_mask);
>   		else

Hmm, since this missing ran into the issue, I suppose some fatty comment 
here is needed and also with some clear distinction between two. 
Perhaps, something like:

	/* Restore enabled features only. */
	xrestore_mask &= task_xfeatures;
-	init_bv = task_xfeatures & ~xrestore_mask;
+	/*
+	 * If the FPU registers do not belong to current, they may still
+	 * contain state from a previous task with features beyond
+	 * current's enabled features. Clear up to max_features to
+	 * prevent state leakage.
+	 */
+	if (test_thread_flag(TIF_NEED_FPU_LOAD))
+		init_bv = fpu_user_cfg.max_features & ~xrestore_mask;
+	else
+		init_bv = task_xfeatures & ~xrestore_mask;

Thanks,
Chang

  parent reply	other threads:[~2026-11-21 22:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 11:26 [PATCH] x86/fpu: Put non-enabled dynamic features into init state on sigreturn Daniel Wade
2026-11-18 20:19 ` Chang S. Bae
2026-11-19  1:38   ` Andrei Vagin
2026-11-19  7:50     ` Andrei Vagin
2026-11-21 22:08     ` Chang S. Bae
2026-11-20 23:34 ` Andrei Vagin
2026-11-21 22:08 ` Chang S. Bae [this message]
2026-11-24  2:07   ` Daniel Wade

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=188d736e-8d8b-449b-8826-d6ff72800379@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=avagin@google.com \
    --cc=bp@alien8.de \
    --cc=danjwade95@gmail.com \
    --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.