public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/3] x86, xsave: remove the redundant access_ok() in setup_rt_frame()
@ 2008-08-13 18:38 Suresh Siddha
  2008-08-13 18:38 ` [patch 2/3] x86, xsave: clear the user buffer before doing fxsave/xsave Suresh Siddha
  2008-08-13 18:38 ` [patch 3/3] x86, xsave: use BUG_ON() instead of BUILD_BUG_ON() Suresh Siddha
  0 siblings, 2 replies; 4+ messages in thread
From: Suresh Siddha @ 2008-08-13 18:38 UTC (permalink / raw)
  To: mingo, hpa, tglx; +Cc: linux-kernel, Suresh Siddha

[-- Attachment #1: remove_redundant_access_ok.patch --]
[-- Type: text/plain, Size: 696 bytes --]

save_i387_xstate() is already doing the required access_ok(). Remove
the redundant access_ok() before it.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---

Index: tip/arch/x86/kernel/signal_64.c
===================================================================
--- tip.orig/arch/x86/kernel/signal_64.c	2008-08-11 15:26:47.000000000 -0700
+++ tip/arch/x86/kernel/signal_64.c	2008-08-11 15:28:52.000000000 -0700
@@ -208,9 +208,6 @@
 		frame = (void __user *)round_down(
 			(unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;
 
-		if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
-			goto give_sigsegv;
-
 		if (save_i387_xstate(fp) < 0)
 			err |= -1;
 	} else

-- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 2/3] x86, xsave: clear the user buffer before doing fxsave/xsave
  2008-08-13 18:38 [patch 1/3] x86, xsave: remove the redundant access_ok() in setup_rt_frame() Suresh Siddha
@ 2008-08-13 18:38 ` Suresh Siddha
  2008-08-13 18:38 ` [patch 3/3] x86, xsave: use BUG_ON() instead of BUILD_BUG_ON() Suresh Siddha
  1 sibling, 0 replies; 4+ messages in thread
From: Suresh Siddha @ 2008-08-13 18:38 UTC (permalink / raw)
  To: mingo, hpa, tglx; +Cc: linux-kernel, Suresh Siddha

[-- Attachment #1: init_fpstate_user_buf.patch --]
[-- Type: text/plain, Size: 1164 bytes --]

fxsave/xsave instructions will not touch all the bytes in the
fxsave/xsave frame. Clear the user buffer before doing fxsave/xsave
directly to user buffer during the sigcontext setup.

This is essentially needed in the context of xsave(for example,
some of the fields in the xsave header are not touched by the xsave
and defined as must be zero).

This will also present uniform and clean context to the user (from
which user can safely do fxrstor/xrstor).

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---

Index: tip/arch/x86/kernel/xsave.c
===================================================================
--- tip.orig/arch/x86/kernel/xsave.c	2008-08-11 15:26:47.000000000 -0700
+++ tip/arch/x86/kernel/xsave.c	2008-08-11 15:44:33.000000000 -0700
@@ -92,6 +92,12 @@
 		return 0;
 	clear_used_math(); /* trigger finit */
 	if (task_thread_info(tsk)->status & TS_USEDFPU) {
+		/*
+	 	 * Start with clearing the user buffer. This will present a
+	 	 * clean context for the bytes not touched by the fxsave/xsave.
+		 */
+		__clear_user(buf, sig_xstate_size);
+
 		if (task_thread_info(tsk)->status & TS_XSAVE)
 			err = xsave_user(buf);
 		else

-- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 3/3] x86, xsave: use BUG_ON() instead of BUILD_BUG_ON()
  2008-08-13 18:38 [patch 1/3] x86, xsave: remove the redundant access_ok() in setup_rt_frame() Suresh Siddha
  2008-08-13 18:38 ` [patch 2/3] x86, xsave: clear the user buffer before doing fxsave/xsave Suresh Siddha
@ 2008-08-13 18:38 ` Suresh Siddha
  2008-08-14  8:56   ` Ingo Molnar
  1 sibling, 1 reply; 4+ messages in thread
From: Suresh Siddha @ 2008-08-13 18:38 UTC (permalink / raw)
  To: mingo, hpa, tglx; +Cc: linux-kernel, Suresh Siddha

[-- Attachment #1: modify_build_bug_on.patch --]
[-- Type: text/plain, Size: 703 bytes --]

All these structure sizes are runtime determined. So use a runtime
bug check.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---

Index: tip/arch/x86/kernel/xsave.c
===================================================================
--- tip.orig/arch/x86/kernel/xsave.c	2008-08-11 15:44:33.000000000 -0700
+++ tip/arch/x86/kernel/xsave.c	2008-08-11 15:45:09.000000000 -0700
@@ -82,8 +82,7 @@
 	if (!access_ok(VERIFY_WRITE, buf, sig_xstate_size))
 		return -EACCES;
 
-	BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
-			sizeof(tsk->thread.xstate->fxsave));
+	BUG_ON(sig_xstate_size < xstate_size);
 
 	if ((unsigned long)buf % 64)
 		printk("save_i387_xstate: bad fpstate %p\n", buf);

-- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 3/3] x86, xsave: use BUG_ON() instead of BUILD_BUG_ON()
  2008-08-13 18:38 ` [patch 3/3] x86, xsave: use BUG_ON() instead of BUILD_BUG_ON() Suresh Siddha
@ 2008-08-14  8:56   ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2008-08-14  8:56 UTC (permalink / raw)
  To: Suresh Siddha; +Cc: hpa, tglx, linux-kernel


* Suresh Siddha <suresh.b.siddha@intel.com> wrote:

> All these structure sizes are runtime determined. So use a runtime bug 
> check.

applied these patches to tip/x86/xsave:

 f65bc21: x86, xsave: use BUG_ON() instead of BUILD_BUG_ON()
 ed40595: x86, xsave: clear the user buffer before doing fxsave/xsave
 ee2b92a: x86, xsave: remove the redundant access_ok() in setup_rt_frame()

thanks Suresh.

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-14  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-13 18:38 [patch 1/3] x86, xsave: remove the redundant access_ok() in setup_rt_frame() Suresh Siddha
2008-08-13 18:38 ` [patch 2/3] x86, xsave: clear the user buffer before doing fxsave/xsave Suresh Siddha
2008-08-13 18:38 ` [patch 3/3] x86, xsave: use BUG_ON() instead of BUILD_BUG_ON() Suresh Siddha
2008-08-14  8:56   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox