lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99baa18c-ae1c-47e1-8bbe-e411570df8f1@intel.com>
Date: Fri, 18 Jul 2025 16:48:06 -0700
From: Sohil Mehta <sohil.mehta@...el.com>
To: Fushuai Wang <wangfushuai@...du.com>
CC: <aruna.ramakrishna@...cle.com>, <aubrey.li@...el.com>, <bp@...en8.de>,
	<brgerst@...il.com>, <chang.seok.bae@...el.com>,
	<dave.hansen@...ux.intel.com>, <hpa@...or.com>,
	<linux-kernel@...r.kernel.org>, <mingo@...hat.com>, <oleg@...hat.com>,
	<peterz@...radead.org>, <rick.p.edgecombe@...el.com>, <seanjc@...gle.com>,
	<tglx@...utronix.de>, <vigbalas@....com>, <x86@...nel.org>
Subject: Re: [PATCH] x86/fpu: Fix potential NULL dereference in
 avx512_status()


>> I am wondering if we ever need to expose the AVX512 usage for kernel
>> threads? If not, then we can do what you currently have but without the
>> CONFIG_X86_DEBUG_FPU restriction. All kernel threads would always print
>> the AVX512_elapsed_ms as -1.
>>

Let's go with this approach. See below.

>> However, this would be a user visible change so we should probably get
>> more inputs. I tried this experiment on an older kernel without the
>> above issue. Among all the active kthreads on my system a handful of
>> them show a valid value for AVX512 usage. The rest of them all show -1.
>>
>> PID: 2594
>> CMD: avahi-daemon: running [SAP.local]
>>  /proc/2594/arch_status content:
>> AVX512_elapsed_ms:      46032
>>
>> PID: 2729
>> CMD: sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
>>  /proc/2729/arch_status content:
>> AVX512_elapsed_ms:      396656
>>

Correction: These aren't really Kthreads. There was a slight error in
the script that I used.

Reporting AVX512 usage doesn't seem very useful for Kthreads. The usage
is mainly for userspace schedulers. Let's just report -1 for all Kthreads.

How about something like below. This should work with and without
CONFIG_X86_DEBUG_FPU.

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 9aa9ac8399ae..10c3994295f2 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1855,19 +1855,18 @@ long fpu_xstate_prctl(int option, unsigned long
arg2)
 #ifdef CONFIG_PROC_PID_ARCH_STATUS
 /*
  * Report the amount of time elapsed in millisecond since last AVX512
- * use in the task.
+ * use in the task. Report -1 if no AVX512 usage.
  */
 static void avx512_status(struct seq_file *m, struct task_struct *task)
 {
-       unsigned long timestamp =
READ_ONCE(x86_task_fpu(task)->avx512_timestamp);
-       long delta;
+       unsigned long timestamp = 0;
+       long delta = -1;

-       if (!timestamp) {
-               /*
-                * Report -1 if no AVX512 usage
-                */
-               delta = -1;
-       } else {
+       /* Do not report AVX512 usage for kernel threads */
+       if (!(task->flags & (PF_KTHREAD | PF_USER_WORKER)))
+               timestamp = READ_ONCE(x86_task_fpu(task)->avx512_timestamp);
+
+       if (timestamp) {
                delta = (long)(jiffies - timestamp);
                /*
                 * Cap to LONG_MAX if time difference > LONG_MAX





Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ