mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix non-lazy GS handling in sys_vm86()
@ 2009-06-06 18:23 Lubomir Rintel
  2009-06-07  7:56 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Lubomir Rintel @ 2009-06-06 18:23 UTC (permalink / raw)
  To: Tejun Heo, Andrew Morton, Linux Kernel Mailing List, x86

This fixes a stack corruption panic or null dereference oops due to
a bad GS in resume_userspace() when returning from sys_vm86() and calling
lockdep_sys_exit().

Only a problem when CONFIG_LOCKDEP and CONFIG_CC_STACKPROTECTOR enabled.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 arch/x86/kernel/vm86_32.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index d7ac84e..177d976 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -287,10 +287,9 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
 	info->regs.pt.ds = 0;
 	info->regs.pt.es = 0;
 	info->regs.pt.fs = 0;
-
-/* we are clearing gs later just before "jmp resume_userspace",
- * because it is not saved/restored.
- */
+#ifndef CONFIG_X86_32_LAZY_GS
+	info->regs.pt.gs = 0;
+#endif
 
 /*
  * The flags register is also special: we cannot trust that the user
@@ -343,10 +342,12 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
 	__asm__ __volatile__(
 		"movl %0,%%esp\n\t"
 		"movl %1,%%ebp\n\t"
-		"mov  %2, %%gs\n\t"
+#ifdef CONFIG_X86_32_LAZY_GS
+		"mov  $0, %%gs\n\t"
+#endif
 		"jmp resume_userspace"
 		: /* no outputs */
-		:"r" (&info->regs), "r" (task_thread_info(tsk)), "r" (0));
+		:"r" (&info->regs), "r" (task_thread_info(tsk)));
 	/* we never return here */
 }
 

-- 
"Excuse all the blood" -- Dead


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

end of thread, other threads:[~2009-06-07 14:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-06 18:23 [PATCH] Fix non-lazy GS handling in sys_vm86() Lubomir Rintel
2009-06-07  7:56 ` Ingo Molnar
2009-06-07 14:23   ` Lubomir Rintel
2009-06-07 14:42     ` [tip:x86/urgent] x86: " tip-bot for Lubomir Rintel

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

all inboxes | Powered by JetHome®