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


Groups > linux.kernel > #1397395 > unrolled thread

[PATCH v5 10/13] x86/xsaves: Fix __fpu_restore_sig() for XSAVES

Started byYu-cheng Yu <yu-cheng.yu@intel.com>
First post2016-05-09 23:00 +0200
Last post2016-05-10 01:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v5 10/13] x86/xsaves: Fix __fpu_restore_sig() for XSAVES Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-09 23:00 +0200
    Re: [PATCH v5 10/13] x86/xsaves: Fix __fpu_restore_sig() for XSAVES Dave Hansen <dave.hansen@linux.intel.com> - 2016-05-10 01:50 +0200

#1397395 — [PATCH v5 10/13] x86/xsaves: Fix __fpu_restore_sig() for XSAVES

FromYu-cheng Yu <yu-cheng.yu@intel.com>
Date2016-05-09 23:00 +0200
Subject[PATCH v5 10/13] x86/xsaves: Fix __fpu_restore_sig() for XSAVES
Message-ID<rx0ry-4yi-49@gated-at.bofh.it>
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().

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@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 d7fdd8c..9c2ff42 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -320,8 +320,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);
 			err = -1;
 		} else {
-- 
1.9.1

[toc] | [next] | [standalone]


#1397519

FromDave Hansen <dave.hansen@linux.intel.com>
Date2016-05-10 01:50 +0200
Message-ID<rx363-7sX-35@gated-at.bofh.it>
In reply to#1397395
On 05/09/2016 01:46 PM, Yu-cheng Yu wrote:
> 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 state,
which we do not want to allow userspace to write.

Reviewed-by: Dave Hansen <dave.hansen@intel.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web