From: Sohil Mehta <sohil.mehta@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>, x86@kernel.org
Cc: Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Sohil Mehta <sohil.mehta@intel.com>,
Sean Christopherson <seanjc@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Vignesh Balasubramanian <vigbalas@amd.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Oleg Nesterov <oleg@redhat.com>,
"Chang S . Bae" <chang.seok.bae@intel.com>,
Brian Gerst <brgerst@gmail.com>,
Eric Biggers <ebiggers@google.com>, Kees Cook <kees@kernel.org>,
Chao Gao <chao.gao@intel.com>,
Fushuai Wang <wangfushuai@baidu.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] x86/fpu: Update the debug flow for x86_task_fpu()
Date: Mon, 21 Jul 2025 14:53:02 -0700 [thread overview]
Message-ID: <20250721215302.3562784-2-sohil.mehta@intel.com> (raw)
In-Reply-To: <20250721215302.3562784-1-sohil.mehta@intel.com>
Kernel threads aren't expected to directly access struct fpu using
x86_task_fpu(). They typically access the FPU state using pairs of
kernel_fpu_begin()/kernel_fpu_end().
When CONFIG_X86_DEBUG_FPU is set, any unintentional usage of
x86_task_fpu() by kernel threads is flagged with a WARN_ON_ONCE().
However, along with the warning, x86_task_fpu() returns a NULL pointer,
which deviates from the flow without the debug config.
Changing the return value could make failures harder to debug by masking
problems or introducing its own set of issues. Keep the behavior of
x86_task_fpu() consistent across debug and non-debug configurations
except for the warning.
Also, update the warning to include PF_USER_WORKER, as these tasks are
treated the same as kernel threads in the FPU context.
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
v2: New patch
This patch is less urgent than Patch 1 which fixes the real issue. I
haven't used a Fixes tag since this addresses a potential problem rather
than fixing an actual bug.
---
arch/x86/kernel/fpu/core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index ea138583dd92..ba16dda697b1 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -58,8 +58,7 @@ DEFINE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
#ifdef CONFIG_X86_DEBUG_FPU
struct fpu *x86_task_fpu(struct task_struct *task)
{
- if (WARN_ON_ONCE(task->flags & PF_KTHREAD))
- return NULL;
+ WARN_ON_ONCE(task->flags & (PF_KTHREAD | PF_USER_WORKER));
return (void *)task + sizeof(*task);
}
--
2.43.0
next prev parent reply other threads:[~2025-07-21 21:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 21:53 [PATCH v2 1/2] x86/fpu: Fix NULL dereference in avx512_status() Sohil Mehta
2025-07-21 21:53 ` Sohil Mehta [this message]
2025-07-21 22:34 ` [PATCH v2 2/2] x86/fpu: Update the debug flow for x86_task_fpu() Dave Hansen
2025-07-22 1:40 ` Sohil Mehta
2025-07-21 22:33 ` [PATCH v2 1/2] x86/fpu: Fix NULL dereference in avx512_status() Dave Hansen
2025-07-22 1:11 ` Sohil Mehta
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=20250721215302.3562784-2-sohil.mehta@intel.com \
--to=sohil.mehta@intel.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=chang.seok.bae@intel.com \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=ebiggers@google.com \
--cc=hpa@zytor.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vigbalas@amd.com \
--cc=wangfushuai@baidu.com \
--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.