Possible cause of SegFaults

From: George Anzinger (george@mvista.com)
Date: Thu Nov 02 2000 - 15:10:08 EST


Linus,

In doing the full preemption testing we found and fixed this little
segfault window. Seems that interrupts are left on for the page fault.
This allows an interrupt prior to fetching the faulting info from CR2.
Result, illegal memory reference, i.e. segfault. I don't know what
interrupt code might touch CR2, but better safe than sorry. Of course,
preemption in this window _IS_ a problem.

Attached find a patch to fix the problem. The patch is on 2.4.0-test9
but should apply to most of 2.4.0 versions.

George

diff -urP -X patch.exclude linux-2.4.0-test9-kb-rts/arch/i386/kernel/traps.c linux/arch/i386/kernel/traps.c
--- linux-2.4.0-test9-kb-rts/arch/i386/kernel/traps.c Mon Oct 30 21:04:29 2000
+++ linux/arch/i386/kernel/traps.c Wed Nov 1 12:42:40 2000
@@ -1028,7 +1028,7 @@
         set_trap_gate(11,&segment_not_present);
         set_trap_gate(12,&stack_segment);
         set_trap_gate(13,&general_protection);
- set_trap_gate(14,&page_fault);
+ set_intr_gate(14,&page_fault);
         set_trap_gate(15,&spurious_interrupt_bug);
         set_trap_gate(16,&coprocessor_error);
         set_trap_gate(17,&alignment_check);
diff -urP -X patch.exclude linux-2.4.0-test9-kb-rts/arch/i386/mm/fault.c linux/arch/i386/mm/fault.c
--- linux-2.4.0-test9-kb-rts/arch/i386/mm/fault.c Mon Oct 30 21:04:29 2000
+++ linux/arch/i386/mm/fault.c Thu Nov 2 09:57:02 2000
@@ -130,7 +130,7 @@
 
         /* get the address */
         __asm__("movl %%cr2,%0":"=r" (address));
-
+ __sti();
         tsk = current;
         mm = tsk->mm;
         info.si_code = SEGV_MAPERR;

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



This archive was generated by hypermail 2b29 : Tue Nov 07 2000 - 21:00:12 EST