LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch] x86, i387: fix ptrace leakage using init_fpu()
@ 2008-03-03 21:01 Suresh Siddha
  2008-03-03 21:12 ` Roland McGrath
  2008-03-04  8:13 ` Ingo Molnar
  0 siblings, 2 replies; 3+ messages in thread
From: Suresh Siddha @ 2008-03-03 21:01 UTC (permalink / raw)
  To: mingo, hpa, tglx; +Cc: linux-kernel, roland

This needs to go into 2.6.25. Thanks.
---

This bug is introduced by the recent i387 merge.

Current usage of unlazy_fpu() in ptrace specific routines is wrong. unlazy_fpu()
will not init fpu if the task never used math. So the ptrace calls
can expose the parent tasks FPU data in some cases.

Replace it with the init_fpu() which will init the math state, if the task
never used math before.

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

diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 763dfc4..60fe801 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -132,7 +132,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
 	if (!cpu_has_fxsr)
 		return -ENODEV;
 
-	unlazy_fpu(target);
+	init_fpu(target);
 
 	return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
 				   &target->thread.i387.fxsave, 0, -1);
@@ -147,7 +147,7 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
 	if (!cpu_has_fxsr)
 		return -ENODEV;
 
-	unlazy_fpu(target);
+	init_fpu(target);
 	set_stopped_child_used_math(target);
 
 	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
@@ -307,7 +307,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,
 	if (!HAVE_HWFP)
 		return fpregs_soft_get(target, regset, pos, count, kbuf, ubuf);
 
-	unlazy_fpu(target);
+	init_fpu(target);
 
 	if (!cpu_has_fxsr)
 		return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
@@ -332,7 +332,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
 	if (!HAVE_HWFP)
 		return fpregs_soft_set(target, regset, pos, count, kbuf, ubuf);
 
-	unlazy_fpu(target);
+	init_fpu(target);
 	set_stopped_child_used_math(target);
 
 	if (!cpu_has_fxsr)

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

* Re: [patch] x86, i387: fix ptrace leakage using init_fpu()
  2008-03-03 21:01 [patch] x86, i387: fix ptrace leakage using init_fpu() Suresh Siddha
@ 2008-03-03 21:12 ` Roland McGrath
  2008-03-04  8:13 ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2008-03-03 21:12 UTC (permalink / raw)
  To: Suresh Siddha; +Cc: mingo, hpa, tglx, linux-kernel

Looks like a good fix to me.

Thanks,
Roland

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

* Re: [patch] x86, i387: fix ptrace leakage using init_fpu()
  2008-03-03 21:01 [patch] x86, i387: fix ptrace leakage using init_fpu() Suresh Siddha
  2008-03-03 21:12 ` Roland McGrath
@ 2008-03-04  8:13 ` Ingo Molnar
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-03-04  8:13 UTC (permalink / raw)
  To: Suresh Siddha; +Cc: hpa, tglx, linux-kernel, roland


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

> This bug is introduced by the recent i387 merge.
> 
> Current usage of unlazy_fpu() in ptrace specific routines is wrong. 
> unlazy_fpu() will not init fpu if the task never used math. So the 
> ptrace calls can expose the parent tasks FPU data in some cases.
> 
> Replace it with the init_fpu() which will init the math state, if the 
> task never used math before.

thanks Suresh, good catch! Applied to x86.git.

	Ingo

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

end of thread, other threads:[~2008-03-04  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-03 21:01 [patch] x86, i387: fix ptrace leakage using init_fpu() Suresh Siddha
2008-03-03 21:12 ` Roland McGrath
2008-03-04  8:13 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).