Skip to contentSkip to conversation

UML - Let page faults always be delivered immediately

PATCH New Jeff Dike 1 participant 1 message Sep 14, 2004 User-mode Linux (UML)

lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 1/1 UML - Let page faults always be delivered immediately

This allows page faults to be delivered when they happen. Without this, it can happen that a page fault will occur when SIGSEGV is disabled, and the host will then just kill UML because it can't invoke the handler.

arch/um/kernel/process.c +1 -5
Index: 2.6.9-rc2/arch/um/kernel/process.c
===================================================================
@@ -57,11 +57,7 @@
 {
 	int flags = altstack ? SA_ONSTACK : 0;
 
-	/* NODEFER is set here because SEGV isn't turned back on when the
-	 * handler is ready to receive signals.  This causes any segfault
-	 * during a copy_user to kill the process because the fault is blocked.
-	 */
-	set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags | SA_NODEFER,
+	set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags, 
 		    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
 	set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, 
 		    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
arch/um/kernel/tt/trap_user.c +7 -0
Index: 2.6.9-rc2/arch/um/kernel/tt/trap_user.c
===================================================================
@@ -23,6 +23,13 @@
 
 	unprotect_kernel_mem();
 
+	/* This is done because to allow SIGSEGV to be delivered inside a SEGV
+	 * handler.  This can happen in copy_user, and if SEGV is disabled,
+	 * the process will die.
+	 */
+	if(sig == SIGSEGV)
+		change_sig(SIGSEGV, 1);
+
 	r = &TASK_REGS(get_current())->tt;
 	save_regs = *r;
 	is_user = user_context(SC_SP(sc));

More recent patches modify files in segv.