Commit e139e955 authored by H. Peter Anvin's avatar H. Peter Anvin

x86, smap: Do not abuse the [f][x]rstor_checking() functions for user space

With SMAP, the [f][x]rstor_checking() functions are no longer usable
for user-space pointers by applying a simple __force cast.  Instead,
create new [f][x]rstor_user() functions which do the proper SMAP
magic.
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/1343171129-2747-3-git-send-email-suresh.b.siddha@intel.com
parent 49b8c695
...@@ -181,11 +181,28 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx) ...@@ -181,11 +181,28 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
"m" (*fx)); "m" (*fx));
} }
static inline int fxrstor_user(struct i387_fxsave_struct __user *fx)
{
if (config_enabled(CONFIG_X86_32))
return user_insn(fxrstor %[fx], "=m" (*fx), [fx] "m" (*fx));
else if (config_enabled(CONFIG_AS_FXSAVEQ))
return user_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx));
/* See comment in fpu_fxsave() below. */
return user_insn(rex64/fxrstor (%[fx]), "=m" (*fx), [fx] "R" (fx),
"m" (*fx));
}
static inline int frstor_checking(struct i387_fsave_struct *fx) static inline int frstor_checking(struct i387_fsave_struct *fx)
{ {
return check_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); return check_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));
} }
static inline int frstor_user(struct i387_fsave_struct __user *fx)
{
return user_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx));
}
static inline void fpu_fxsave(struct fpu *fpu) static inline void fpu_fxsave(struct fpu *fpu)
{ {
if (config_enabled(CONFIG_X86_32)) if (config_enabled(CONFIG_X86_32))
......
...@@ -315,7 +315,7 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only) ...@@ -315,7 +315,7 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
if ((unsigned long)buf % 64 || fx_only) { if ((unsigned long)buf % 64 || fx_only) {
u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE; u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
xrstor_state(init_xstate_buf, init_bv); xrstor_state(init_xstate_buf, init_bv);
return fxrstor_checking((__force void *) buf); return fxrstor_user(buf);
} else { } else {
u64 init_bv = pcntxt_mask & ~xbv; u64 init_bv = pcntxt_mask & ~xbv;
if (unlikely(init_bv)) if (unlikely(init_bv))
...@@ -323,9 +323,9 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only) ...@@ -323,9 +323,9 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
return xrestore_user(buf, xbv); return xrestore_user(buf, xbv);
} }
} else if (use_fxsr()) { } else if (use_fxsr()) {
return fxrstor_checking((__force void *) buf); return fxrstor_user(buf);
} else } else
return frstor_checking((__force void *) buf); return frstor_user(buf);
} }
int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size) int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
......
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