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] [day] [month] [year] [list]
Message-ID: <20250214010607.7067-3-chang.seok.bae@intel.com>
Date: Thu, 13 Feb 2025 17:06:07 -0800
From: "Chang S. Bae" <chang.seok.bae@...el.com>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org,
	tglx@...utronix.de,
	mingo@...hat.com,
	bp@...en8.de,
	dave.hansen@...ux.intel.com,
	aruna.ramakrishna@...cle.com,
	TonyWWang-oc@...oxin.com,
	chang.seok.bae@...el.com
Subject: [PATCH 2/2] x86/pkeys: Simplify PKRU update in signal frame

Commit ae6012d72fa6 ("x86/pkeys: Ensure updated PKRU value is XRSTOR'd")
modified the signal delivery logic to always set the PKRU bit in
xregs_state->header->xfeatures.

The change currently derives the bitmask value using XGETBV(1), rather
than reading the already written value directly from the buffer. Thus,
this approach induces an unnecessary dependency on XGETBV1 for the PKRU
feature.

Eliminate the dependency by using the established helper function.
Subsequently, remove the unused mask argument from
update_pkru_in_sigframe().

Signed-off-by: Chang S. Bae <chang.seok.bae@...el.com>
Cc: Aruna Ramakrishna <aruna.ramakrishna@...cle.com>
Cc: Tony W Wang-oc <TonyWWang-oc@...oxin.com>
---
 arch/x86/kernel/fpu/xstate.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h
index 27e20236bbbb..f3fc3369a135 100644
--- a/arch/x86/kernel/fpu/xstate.h
+++ b/arch/x86/kernel/fpu/xstate.h
@@ -84,18 +84,15 @@ static inline int set_xfeature_in_sigframe(struct xregs_state __user *xbuf, u64
 /*
  * Update the value of PKRU register that was already pushed onto the signal frame.
  */
-static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 mask, u32 pkru)
+static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u32 pkru)
 {
-	u64 xstate_bv;
 	int err;
 
 	if (unlikely(!cpu_feature_enabled(X86_FEATURE_OSPKE)))
 		return 0;
 
 	/* Mark PKRU as in-use so that it is restored correctly. */
-	xstate_bv = (mask & xfeatures_in_use()) | XFEATURE_MASK_PKRU;
-
-	err =  __put_user(xstate_bv, &buf->header.xfeatures);
+	err = set_xfeature_in_sigframe(buf, XFEATURE_MASK_PKRU);
 	if (err)
 		return err;
 
@@ -316,7 +313,7 @@ static inline int xsave_to_user_sigframe(struct xregs_state __user *buf, u32 pkr
 	clac();
 
 	if (!err)
-		err = update_pkru_in_sigframe(buf, mask, pkru);
+		err = update_pkru_in_sigframe(buf, pkru);
 
 	return err;
 }
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ