public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Possible cause of SegFaults
@ 2000-11-02 20:10 George Anzinger
  0 siblings, 0 replies; only message in thread
From: George Anzinger @ 2000-11-02 20:10 UTC (permalink / raw)
  To: Linus Torvalds, linux-kernel@vger.redhat.com

[-- Attachment #1: Type: text/plain, Size: 525 bytes --]

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

[-- Attachment #2: segfault.patch --]
[-- Type: text/plain, Size: 980 bytes --]

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;

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

only message in thread, other threads:[~2000-11-02 20:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-02 20:10 Possible cause of SegFaults George Anzinger

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