public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] stack overflow safe kdump (i386) - fault
@ 2005-11-28 18:01 Fernando Luis Vazquez Cao
  0 siblings, 0 replies; only message in thread
From: Fernando Luis Vazquez Cao @ 2005-11-28 18:01 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: linux-kernel, fastboot

When we have a bloated stack it is likely that it ends up making an
invalid memory access that causes a page fault. Take this case into
account in the page fault code.

---

diff -urNp linux-2.6.15-rc2/arch/i386/mm/fault.c
linux-2.6.15-rc2-sov/arch/i386/mm/fault.c
--- linux-2.6.15-rc2/arch/i386/mm/fault.c	2005-11-29 01:46:34.000000000
+0900
+++ linux-2.6.15-rc2-sov/arch/i386/mm/fault.c	2005-11-29
01:48:21.000000000 +0900
@@ -245,6 +245,11 @@ fastcall void __kprobes do_page_fault(st
 		local_irq_enable();
 
 	tsk = current;
+	/* We may have invalid '*current' due to a stack overflow. */
+	if (!virt_addr_valid(tsk)) {
+		printk("do_page_fault: Discarding invalid 'current' struct
task_struct * = 0x%p\n", tsk);
+		tsk = NULL;
+	}
 
 	si_code = SEGV_MAPERR;
 
@@ -271,7 +276,14 @@ fastcall void __kprobes do_page_fault(st
 		goto bad_area_nosemaphore;
 	} 
 
-	mm = tsk->mm;
+	mm = NULL;
+	/* We may have invalid 'tsk' due to a i386 stack overflow */
+	if (tsk)
+		mm = tsk->mm;
+	if (mm && !virt_addr_valid(mm)) {
+		printk("do_page_fault: Discarding invalid current->mm struct
mm_struct * = 0x%p\n", mm);
+		mm = NULL;
+	}
 
 	/*
 	 * If we're in an interrupt, have no user context or are running in an



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-28 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-28 18:01 [PATCH 4/4] stack overflow safe kdump (i386) - fault Fernando Luis Vazquez Cao

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