diff options
author | 2021-06-23 14:01:36 +0200 | |
---|---|---|
committer | 2021-06-23 17:49:46 +0200 | |
commit | 43be46e89698a41dbf4fff81a322f4c2ae21b5e2 (patch) | |
tree | f5db3fd5782445fb0a61d4bf78634789e10fa393 /arch/x86/include/asm/fpu/xstate.h | |
parent | x86/fpu: Limit xstate copy size in xstateregs_set() (diff) | |
download | linux-dev-43be46e89698a41dbf4fff81a322f4c2ae21b5e2.tar.xz linux-dev-43be46e89698a41dbf4fff81a322f4c2ae21b5e2.zip |
x86/fpu: Sanitize xstateregs_set()
xstateregs_set() operates on a stopped task and tries to copy the provided
buffer into the task's fpu.state.xsave buffer.
Any error while copying or invalid state detected after copying results in
wiping the target task's FPU state completely including supervisor states.
That's just wrong. The caller supplied invalid data or has a problem with
unmapped memory, so there is absolutely no justification to corrupt the
target state.
Fix this with the following modifications:
1) If data has to be copied from userspace, allocate a buffer and copy from
user first.
2) Use copy_kernel_to_xstate() unconditionally so that header checking
works correctly.
3) Return on error without corrupting the target state.
This prevents corrupting states and lets the caller deal with the problem
it caused in the first place.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121452.214903673@linutronix.de
Diffstat (limited to 'arch/x86/include/asm/fpu/xstate.h')
-rw-r--r-- | arch/x86/include/asm/fpu/xstate.h | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index d22e973845c6..1bb2d16f485b 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -111,8 +111,4 @@ void copy_supervisor_to_kernel(struct xregs_state *xsave); void copy_dynamic_supervisor_to_kernel(struct xregs_state *xstate, u64 mask); void copy_kernel_to_dynamic_supervisor(struct xregs_state *xstate, u64 mask); - -/* Validate an xstate header supplied by userspace (ptrace or sigreturn) */ -int validate_user_xstate_header(const struct xstate_header *hdr); - #endif |