diff options
author | Eric Biggers <ebiggers@google.com> | 2017-09-24 06:59:11 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-09-26 03:43:48 -0400 |
commit | 3d703477bcfe8bb57079d97198cf1e342fe1fef9 (patch) | |
tree | b531392801d72bb200f49859e9d1fc7eb09e593a | |
parent | af2c4322d986a08a6e793b74b83a62b325019c20 (diff) |
x86/fpu: Eliminate the 'xfeatures' local variable in copy_user_to_xstate()
We now have this field in hdr.xfeatures.
Signed-off-by: Eric Biggers <ebiggers@google.com>
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: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Kevin Hao <haokexin@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael Halcrow <mhalcrow@google.com>
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: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Cc: kernel-hardening@lists.openwall.com
Link: http://lkml.kernel.org/r/20170924105913.9157-9-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/fpu/xstate.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 0cd7b73c25e8..b6d78b78b5c2 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c | |||
@@ -1197,7 +1197,6 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf) | |||
1197 | { | 1197 | { |
1198 | unsigned int offset, size; | 1198 | unsigned int offset, size; |
1199 | int i; | 1199 | int i; |
1200 | u64 xfeatures; | ||
1201 | u64 allowed_features; | 1200 | u64 allowed_features; |
1202 | struct xstate_header hdr; | 1201 | struct xstate_header hdr; |
1203 | 1202 | ||
@@ -1207,20 +1206,18 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf) | |||
1207 | if (__copy_from_user(&hdr, ubuf + offset, size)) | 1206 | if (__copy_from_user(&hdr, ubuf + offset, size)) |
1208 | return -EFAULT; | 1207 | return -EFAULT; |
1209 | 1208 | ||
1210 | xfeatures = hdr.xfeatures; | ||
1211 | |||
1212 | /* | 1209 | /* |
1213 | * Reject if the user sets any disabled or supervisor features: | 1210 | * Reject if the user sets any disabled or supervisor features: |
1214 | */ | 1211 | */ |
1215 | allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR; | 1212 | allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR; |
1216 | 1213 | ||
1217 | if (xfeatures & ~allowed_features) | 1214 | if (hdr.xfeatures & ~allowed_features) |
1218 | return -EINVAL; | 1215 | return -EINVAL; |
1219 | 1216 | ||
1220 | for (i = 0; i < XFEATURE_MAX; i++) { | 1217 | for (i = 0; i < XFEATURE_MAX; i++) { |
1221 | u64 mask = ((u64)1 << i); | 1218 | u64 mask = ((u64)1 << i); |
1222 | 1219 | ||
1223 | if (xfeatures & mask) { | 1220 | if (hdr.xfeatures & mask) { |
1224 | void *dst = __raw_xsave_addr(xsave, 1 << i); | 1221 | void *dst = __raw_xsave_addr(xsave, 1 << i); |
1225 | 1222 | ||
1226 | offset = xstate_offsets[i]; | 1223 | offset = xstate_offsets[i]; |
@@ -1231,7 +1228,7 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf) | |||
1231 | } | 1228 | } |
1232 | } | 1229 | } |
1233 | 1230 | ||
1234 | if (xfeatures_mxcsr_quirk(xfeatures)) { | 1231 | if (xfeatures_mxcsr_quirk(hdr.xfeatures)) { |
1235 | offset = offsetof(struct fxregs_state, mxcsr); | 1232 | offset = offsetof(struct fxregs_state, mxcsr); |
1236 | size = MXCSR_AND_FLAGS_SIZE; | 1233 | size = MXCSR_AND_FLAGS_SIZE; |
1237 | if (__copy_from_user(&xsave->i387.mxcsr, ubuf + offset, size)) | 1234 | if (__copy_from_user(&xsave->i387.mxcsr, ubuf + offset, size)) |
@@ -1247,7 +1244,7 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf) | |||
1247 | /* | 1244 | /* |
1248 | * Add back in the features that came in from userspace: | 1245 | * Add back in the features that came in from userspace: |
1249 | */ | 1246 | */ |
1250 | xsave->header.xfeatures |= xfeatures; | 1247 | xsave->header.xfeatures |= hdr.xfeatures; |
1251 | 1248 | ||
1252 | return 0; | 1249 | return 0; |
1253 | } | 1250 | } |