Commit af9086a7 authored by Brian Gerst's avatar Brian Gerst Committed by Russell King

[PATCH] SSE related security hole

Initialize the saved FPU/XMM state in the task struct and fall through
to restore_fpu() to make sure that all state is fully initialized.

This means that old SSE/SSE2 information cannot ever leak into newly
created processes. 
parent 0540fcdf
...@@ -31,13 +31,21 @@ ...@@ -31,13 +31,21 @@
* value at reset if we support XMM instructions and then * value at reset if we support XMM instructions and then
* remeber the current task has used the FPU. * remeber the current task has used the FPU.
*/ */
void init_fpu(void) void init_fpu(struct task_struct *tsk)
{ {
__asm__("fninit"); if (cpu_has_fxsr) {
if ( cpu_has_xmm ) memset(&tsk->thread.i387.fxsave, 0, sizeof(struct i387_fxsave_struct));
load_mxcsr(0x1f80); tsk->thread.i387.fxsave.cwd = 0x37f;
if (cpu_has_xmm)
current->used_math = 1; tsk->thread.i387.fxsave.mxcsr = 0x1f80;
} else {
memset(&tsk->thread.i387.fsave, 0, sizeof(struct i387_fsave_struct));
tsk->thread.i387.fsave.cwd = 0xffff037f;
tsk->thread.i387.fsave.swd = 0xffff0000;
tsk->thread.i387.fsave.twd = 0xffffffff;
tsk->thread.i387.fsave.fos = 0xffff0000;
}
tsk->used_math = 1;
} }
/* /*
......
...@@ -757,13 +757,12 @@ asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs, ...@@ -757,13 +757,12 @@ asmlinkage void do_spurious_interrupt_bug(struct pt_regs * regs,
*/ */
asmlinkage void math_state_restore(struct pt_regs regs) asmlinkage void math_state_restore(struct pt_regs regs)
{ {
struct task_struct *tsk = current;
clts(); /* Allow maths ops (or we recurse) */ clts(); /* Allow maths ops (or we recurse) */
if (current->used_math) { if (!tsk->used_math)
restore_fpu(current); init_fpu(tsk);
} else { restore_fpu(tsk);
init_fpu();
}
set_thread_flag(TIF_USEDFPU); /* So we fnsave on switch_to() */ set_thread_flag(TIF_USEDFPU); /* So we fnsave on switch_to() */
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <asm/sigcontext.h> #include <asm/sigcontext.h>
#include <asm/user.h> #include <asm/user.h>
extern void init_fpu(void); extern void init_fpu(struct task_struct *);
/* /*
* FPU lazy state save handling... * FPU lazy state save handling...
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment