[PATCH 3/5] stack overflow safe kdump (2.6.16-rc1-i386) - fault

From: Fernando Luis Vazquez Cao
Date: Wed Jan 25 2006 - 01:51:42 EST


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

Signed-off-by: Fernando Vazquez <fernando@xxxxxxxxxxxxxxxxx>
---

diff -urNp linux-2.6.16-rc1/arch/i386/mm/fault.c linux-2.6.16-rc1-sov/arch/i386/mm/fault.c
--- linux-2.6.16-rc1/arch/i386/mm/fault.c 2006-01-03 12:21:10.000000000 +0900
+++ linux-2.6.16-rc1-sov/arch/i386/mm/fault.c 2006-01-25 14:43:13.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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/