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>] [day] [month] [year] [list]
Message-ID: <32f5ce15-e9e8-4351-a231-c23ebb4b083c@suse.com>
Date: Thu, 4 Jul 2024 13:32:24 +0200
From: Jan Beulich <jbeulich@...e.com>
To: lkml <linux-kernel@...r.kernel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 the arch/x86 maintainers <x86@...nel.org>
Subject: [PATCH] x86/xstate: don't globally disable TILE_DATA just on its own

In XCR0 certain bits need to be simultaneously set / clear. Since
fpu__init_cpu_xstate() wants to pass fpu_user_cfg.max_features to
XSETBV, make sure invalid values cannot end up there in case XFD is not
available. Do the clearing right for fpu_kernel_cfg.max_features (which
fpu_user_cfg.max_features is derived from), to avoid that field holding
an invalid combination of bits either.

Fixes: 2ae996e0c1a3 ("x86/fpu: Calculate the default sizes independently")
Signed-off-by: Jan Beulich <jbeulich@...e.com>
---
#GP observed in a virtualized environment with AMX enabled, but XFD off
(which is an architecturally legal combination of features, afaict).

--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@ -49,6 +49,9 @@
 /* Features which are dynamically enabled for a process on request */
 #define XFEATURE_MASK_USER_DYNAMIC	XFEATURE_MASK_XTILE_DATA
 
+/* Features which the above ones are tied to. */
+#define XFEATURE_MASK_USER_DYN_DEPS	XFEATURE_MASK_XTILE_CFG
+
 /* All currently supported supervisor features */
 #define XFEATURE_MASK_SUPERVISOR_SUPPORTED (XFEATURE_MASK_PASID | \
 					    XFEATURE_MASK_CET_USER)
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -799,8 +799,15 @@ void __init fpu__init_system_xstate(unsi
 			fpu_kernel_cfg.max_features &= ~BIT_ULL(i);
 	}
 
-	if (!cpu_feature_enabled(X86_FEATURE_XFD))
-		fpu_kernel_cfg.max_features &= ~XFEATURE_MASK_USER_DYNAMIC;
+	if (!cpu_feature_enabled(X86_FEATURE_XFD)) {
+		/*
+		 * Besides disabling all dynamic features, also disable all
+		 * of their dependents, such that the resulting value can be
+		 * handed to XSETBV without causing #GP.
+		 */
+		fpu_kernel_cfg.max_features &= ~(XFEATURE_MASK_USER_DYNAMIC |
+						 XFEATURE_MASK_USER_DYN_DEPS);
+	}
 
 	if (!cpu_feature_enabled(X86_FEATURE_XSAVES))
 		fpu_kernel_cfg.max_features &= XFEATURE_MASK_USER_SUPPORTED;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ