Commit 7b9094c6 authored by Ingo Molnar's avatar Ingo Molnar

x86/fpu: Remove 'kbuf' parameter from the copy_user_to_xstate() API

No change in functionality.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/20170923130016.21448-14-mingo@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 59dffa4e
...@@ -51,5 +51,5 @@ int using_compacted_format(void); ...@@ -51,5 +51,5 @@ int using_compacted_format(void);
int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset, unsigned int size); int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset, unsigned int size);
int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned int offset, unsigned int size); int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned int offset, unsigned int size);
int copy_kernel_to_xstate(const void *kbuf, struct xregs_state *xsave); int copy_kernel_to_xstate(const void *kbuf, struct xregs_state *xsave);
int copy_user_to_xstate(const void *kbuf, const void __user *ubuf, struct xregs_state *xsave); int copy_user_to_xstate(const void __user *ubuf, struct xregs_state *xsave);
#endif #endif
...@@ -138,7 +138,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset, ...@@ -138,7 +138,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
if (kbuf) if (kbuf)
ret = copy_kernel_to_xstate(kbuf, xsave); ret = copy_kernel_to_xstate(kbuf, xsave);
else else
ret = copy_user_to_xstate(kbuf, ubuf, xsave); ret = copy_user_to_xstate(ubuf, xsave);
} else { } else {
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1); ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
} }
......
...@@ -323,13 +323,10 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) ...@@ -323,13 +323,10 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
*/ */
fpu__drop(fpu); fpu__drop(fpu);
if (using_compacted_format()) { if (using_compacted_format())
err = copy_user_to_xstate(NULL, buf_fx, err = copy_user_to_xstate(buf_fx, &fpu->state.xsave);
&fpu->state.xsave); else
} else { err = __copy_from_user(&fpu->state.xsave, buf_fx, state_size);
err = __copy_from_user(&fpu->state.xsave,
buf_fx, state_size);
}
if (err || __copy_from_user(&env, buf, sizeof(env))) { if (err || __copy_from_user(&env, buf, sizeof(env))) {
fpstate_init(&fpu->state); fpstate_init(&fpu->state);
......
...@@ -1142,8 +1142,7 @@ int copy_kernel_to_xstate(const void *kbuf, struct xregs_state *xsave) ...@@ -1142,8 +1142,7 @@ int copy_kernel_to_xstate(const void *kbuf, struct xregs_state *xsave)
* there we check the CPU has XSAVES and a whole standard-sized buffer * there we check the CPU has XSAVES and a whole standard-sized buffer
* exists. * exists.
*/ */
int copy_user_to_xstate(const void *kbuf, const void __user *ubuf, int copy_user_to_xstate(const void __user *ubuf, struct xregs_state *xsave)
struct xregs_state *xsave)
{ {
unsigned int offset, size; unsigned int offset, size;
int i; int i;
...@@ -1153,12 +1152,8 @@ int copy_user_to_xstate(const void *kbuf, const void __user *ubuf, ...@@ -1153,12 +1152,8 @@ int copy_user_to_xstate(const void *kbuf, const void __user *ubuf,
offset = offsetof(struct xregs_state, header); offset = offsetof(struct xregs_state, header);
size = sizeof(xfeatures); size = sizeof(xfeatures);
if (kbuf) { if (__copy_from_user(&xfeatures, ubuf + offset, size))
memcpy(&xfeatures, kbuf + offset, size); return -EFAULT;
} else {
if (__copy_from_user(&xfeatures, ubuf + offset, size))
return -EFAULT;
}
/* /*
* Reject if the user sets any disabled or supervisor features: * Reject if the user sets any disabled or supervisor features:
...@@ -1177,12 +1172,8 @@ int copy_user_to_xstate(const void *kbuf, const void __user *ubuf, ...@@ -1177,12 +1172,8 @@ int copy_user_to_xstate(const void *kbuf, const void __user *ubuf,
offset = xstate_offsets[i]; offset = xstate_offsets[i];
size = xstate_sizes[i]; size = xstate_sizes[i];
if (kbuf) { if (__copy_from_user(dst, ubuf + offset, size))
memcpy(dst, kbuf + offset, size); return -EFAULT;
} else {
if (__copy_from_user(dst, ubuf + offset, size))
return -EFAULT;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment