summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Huey <me@kylehuey.com>2023-01-09 13:02:13 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-14 10:23:27 +0100
commit3c1940c54922c2f5d434f11f568045dc5e5154f4 (patch)
tree04e3469723be702d621d60b081cc3a7aeb9d2bfc
parent3f1c81426a9f1cf038b00994dab1ececa72de56b (diff)
downloadlinux-3c1940c54922c2f5d434f11f568045dc5e5154f4.tar.gz
linux-3c1940c54922c2f5d434f11f568045dc5e5154f4.tar.bz2
linux-3c1940c54922c2f5d434f11f568045dc5e5154f4.zip
x86/fpu: Emulate XRSTOR's behavior if the xfeatures PKRU bit is not set
commit d7e5aceace514a2b1b3ca3dc44f93f1704766ca7 upstream The hardware XRSTOR instruction resets the PKRU register to its hardware init value (namely 0) if the PKRU bit is not set in the xfeatures mask. Emulating that here restores the pre-5.14 behavior for PTRACE_SET_REGSET with NT_X86_XSTATE, and makes sigreturn (which still uses XRSTOR) and behave identically. Fixes: e84ba47e313d ("x86/fpu: Hook up PKRU into ptrace()") Signed-off-by: Kyle Huey <me@kylehuey.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/all/20221115230932.7126-6-khuey%40kylehuey.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/x86/kernel/fpu/xstate.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index fe9050c60adc..8bbf37c0bebe 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1168,7 +1168,8 @@ static int copy_uabi_to_xstate(struct xregs_state *xsave, const void *kbuf,
xpkru = __raw_xsave_addr(xsave, XFEATURE_PKRU);
*pkru = xpkru->pkru;
- }
+ } else
+ *pkru = 0;
/*
* The state that came in from userspace was user-state only.