diff options
author | Andy Lutomirski <luto@amacapital.net> | 2014-11-22 21:00:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-11-23 16:56:18 -0500 |
commit | af726f21ed8af2cdaa4e93098dc211521218ae65 (patch) | |
tree | d3546c0fe44e49d283ed3d0ced3b92873f28df34 /arch/x86/kernel/traps.c | |
parent | fc14f9c1272f62c3e8d01300f52467c0d9af50f9 (diff) |
x86_64, traps: Fix the espfix64 #DF fixup and rewrite it in C
There's nothing special enough about the espfix64 double fault fixup to
justify writing it in assembly. Move it to C.
This also fixes a bug: if the double fault came from an IST stack, the
old asm code would return to a partially uninitialized stack frame.
Fixes: 3891a04aafd668686239349ea58f3314ea2af86b
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/kernel/traps.c')
-rw-r--r-- | arch/x86/kernel/traps.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 0d0e922fafc1..819662746e23 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -259,6 +259,30 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code) | |||
259 | static const char str[] = "double fault"; | 259 | static const char str[] = "double fault"; |
260 | struct task_struct *tsk = current; | 260 | struct task_struct *tsk = current; |
261 | 261 | ||
262 | #ifdef CONFIG_X86_ESPFIX64 | ||
263 | extern unsigned char native_irq_return_iret[]; | ||
264 | |||
265 | /* | ||
266 | * If IRET takes a non-IST fault on the espfix64 stack, then we | ||
267 | * end up promoting it to a doublefault. In that case, modify | ||
268 | * the stack to make it look like we just entered the #GP | ||
269 | * handler from user space, similar to bad_iret. | ||
270 | */ | ||
271 | if (((long)regs->sp >> PGDIR_SHIFT) == ESPFIX_PGD_ENTRY && | ||
272 | regs->cs == __KERNEL_CS && | ||
273 | regs->ip == (unsigned long)native_irq_return_iret) | ||
274 | { | ||
275 | struct pt_regs *normal_regs = task_pt_regs(current); | ||
276 | |||
277 | /* Fake a #GP(0) from userspace. */ | ||
278 | memmove(&normal_regs->ip, (void *)regs->sp, 5*8); | ||
279 | normal_regs->orig_ax = 0; /* Missing (lost) #GP error code */ | ||
280 | regs->ip = (unsigned long)general_protection; | ||
281 | regs->sp = (unsigned long)&normal_regs->orig_ax; | ||
282 | return; | ||
283 | } | ||
284 | #endif | ||
285 | |||
262 | exception_enter(); | 286 | exception_enter(); |
263 | /* Return not checked because double check cannot be ignored */ | 287 | /* Return not checked because double check cannot be ignored */ |
264 | notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV); | 288 | notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV); |