Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1440742

[tip:x86/fpu] x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES

From tip-bot for Yu-cheng Yu <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:x86/fpu] x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES
Date 2016-07-11 18:20 +0200
Message-ID <rTM66-10U-13@gated-at.bofh.it> (permalink)
References <rTJhU-7vn-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  1fc2b67b43d5001b92b3a002b988884ad0137e99
Gitweb:     http://git.kernel.org/tip/1fc2b67b43d5001b92b3a002b988884ad0137e99
Author:     Yu-cheng Yu <yu-cheng.yu@intel.com>
AuthorDate: Mon, 11 Jul 2016 09:18:54 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 11 Jul 2016 16:43:59 +0200

x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES

When the kernel is using XSAVES compacted format, we cannot do
__copy_from_user() from a signal frame, which has standard-format data.
Fix it by using copyin_to_xsaves(), which converts between formats and
filters out all supervisor states that we do not allow userspace to
write.

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Cc: H. Peter Anvin <h.peter.anvin@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi V Shankar <ravi.v.shankar@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1468253937-40008-2-git-send-email-fenghua.yu@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/fpu/signal.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 8aa96cb..9e231d8 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -323,8 +323,15 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
 		 */
 		fpu__drop(fpu);
 
-		if (__copy_from_user(&fpu->state.xsave, buf_fx, state_size) ||
-		    __copy_from_user(&env, buf, sizeof(env))) {
+		if (using_compacted_format()) {
+			err = copyin_to_xsaves(NULL, buf_fx,
+					       &fpu->state.xsave);
+		} else {
+			err = __copy_from_user(&fpu->state.xsave,
+					       buf_fx, state_size);
+		}
+
+		if (err || __copy_from_user(&env, buf, sizeof(env))) {
 			fpstate_init(&fpu->state);
 			trace_x86_fpu_init_state(fpu);
 			err = -1;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] x86/fpu/xstate: Fix XSAVES issues - Part 3 "Fenghua Yu" <fenghua.yu@intel.com> - 2016-07-11 15:20 +0200
  [PATCH 1/4] x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES "Fenghua Yu" <fenghua.yu@intel.com> - 2016-07-11 15:20 +0200
    [tip:x86/fpu] x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES tip-bot for Yu-cheng Yu <tipbot@zytor.com> - 2016-07-11 18:20 +0200
  [PATCH 2/4] x86/fpu/xstate: Return NULL for disabled xstate component address "Fenghua Yu" <fenghua.yu@intel.com> - 2016-07-11 15:20 +0200
    [tip:x86/fpu] x86/fpu/xstate: Return NULL for disabled xstate  component address tip-bot for Yu-cheng Yu <tipbot@zytor.com> - 2016-07-11 18:20 +0200
  [PATCH 3/4] x86/fpu/xstate: Fix fpstate_init() for XRSTORS "Fenghua Yu" <fenghua.yu@intel.com> - 2016-07-11 15:20 +0200
    [tip:x86/fpu] x86/fpu/xstate: Fix fpstate_init() for XRSTORS tip-bot for Yu-cheng Yu <tipbot@zytor.com> - 2016-07-11 18:20 +0200

csiph-web