mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Fenghua Yu" <fenghua.yu@intel.com>
To: "Ingo Molnar" <mingo@elte.hu>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"H. Peter Anvin" <h.peter.anvin@intel.com>,
	"Dave Hansen" <dave.hansen@intel.com>,
	"Ravi V Shankar" <ravi.v.shankar@intel.com>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>,
	"Fenghua Yu" <fenghua.yu@intel.com>, "x86" <x86@kernel.org>,
	"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/4] x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES
Date: Mon, 11 Jul 2016 09:18:54 -0700	[thread overview]
Message-ID: <1468253937-40008-2-git-send-email-fenghua.yu@intel.com> (raw)
In-Reply-To: <1468253937-40008-1-git-send-email-fenghua.yu@intel.com>

From: Yu-cheng Yu <yu-cheng.yu@intel.com>

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>
---
 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;
-- 
2.5.0

  reply	other threads:[~2016-07-11 13:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11 16:18 [PATCH 0/4] x86/fpu/xstate: Fix XSAVES issues - Part 3 Fenghua Yu
2016-07-11 16:18 ` Fenghua Yu [this message]
2016-07-11 16:12   ` [tip:x86/fpu] x86/fpu/xstate: Fix __fpu_restore_sig() for XSAVES tip-bot for Yu-cheng Yu
2016-07-11 16:18 ` [PATCH 2/4] x86/fpu/xstate: Return NULL for disabled xstate component address Fenghua Yu
2016-07-11 16:13   ` [tip:x86/fpu] " tip-bot for Yu-cheng Yu
2016-07-11 16:18 ` [PATCH 3/4] x86/fpu/xstate: Fix fpstate_init() for XRSTORS Fenghua Yu
2016-07-11 16:13   ` [tip:x86/fpu] " tip-bot for Yu-cheng Yu
2016-07-11 16:18 ` [PATCH 4/4] x86/fpu/xstate: Re-enable XSAVES Fenghua Yu
2016-07-11 16:14   ` [tip:x86/fpu] " tip-bot for Yu-cheng Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468253937-40008-2-git-send-email-fenghua.yu@intel.com \
    --to=fenghua.yu@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=h.peter.anvin@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=ravi.v.shankar@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yu-cheng.yu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome