[RFC][PATCH 2/8] x86/fpu: hook up PKRU into signal user ABIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>

One nice thing about having PKRU be XSAVE-managed is that it gets naturally
exposed into the XSAVE-using ABIs.  Now that XSAVE will not be used to
manage PKRU, these ABIs need to be manually enabled to deal with PKRU.

For signals (the restore_hwregs_from_user() path), it's quite
straightforward.  restore_hwregs_from_user() will update PKRU in from
the user signal buffer.  Ensure that PKRU is shuffled into the thread
storage.

Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
---

 b/arch/x86/kernel/fpu/signal.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -puN arch/x86/kernel/fpu/signal.c~fpu-sig-stash-pkru arch/x86/kernel/fpu/signal.c
--- a/arch/x86/kernel/fpu/signal.c~fpu-sig-stash-pkru	2021-06-22 14:49:07.899051760 -0700
+++ b/arch/x86/kernel/fpu/signal.c	2021-06-22 14:49:07.903051760 -0700
@@ -233,6 +233,13 @@ static int restore_hwregs_from_user(void
 
 		if (!ret && unlikely(init_bv))
 			os_xrstor(&init_fpstate.xsave, init_bv);
+
+		/*
+		 * PKRU may have been modified by XRSTOR,
+		 * save the possibly updated value:
+		 */
+		current->thread.pkru = read_pkru();
+
 		return ret;
 	} else if (use_fxsr()) {
 		return fxrstor_from_user_sigframe(buf);
_




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux