mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 10/11] - UML - Don't delay segfaults
@ 2004-11-13  2:01 Jeff Dike
  0 siblings, 0 replies; only message in thread
From: Jeff Dike @ 2004-11-13  2:01 UTC (permalink / raw)
  To: akpm, Blaisorblade, Bodo Stroesser; +Cc: linux-kernel

>From Bodo Stroesser - This one covers the fact, that the SIGSEGV
signal, which is created by force_sigsegv() in case of an error in
handle_signal(), is not delivered to the user immediately. In the
worst case it even could be masked if a sigprocmask() systemcall
follows immediately after return from kernel. The patch is relevant
for other architectures, too.

Signed-off-by: Jeff Dike <jdike@addtoit.com>

Index: 2.6.9/arch/um/kernel/signal_kern.c
===================================================================
--- 2.6.9.orig/arch/um/kernel/signal_kern.c	2004-11-12 16:24:20.000000000 -0500
+++ 2.6.9/arch/um/kernel/signal_kern.c	2004-11-12 16:24:21.000000000 -0500
@@ -38,9 +38,9 @@
 /*
  * OK, we're invoking a handler
  */	
-static void handle_signal(struct pt_regs *regs, unsigned long signr,
-			  struct k_sigaction *ka, siginfo_t *info,
-			  sigset_t *oldset)
+static int handle_signal(struct pt_regs *regs, unsigned long signr,
+			 struct k_sigaction *ka, siginfo_t *info,
+			 sigset_t *oldset)
 {
 	unsigned long sp;
 	int err;
@@ -94,23 +94,25 @@
 		recalc_sigpending();
 		spin_unlock_irq(&current->sighand->siglock);
 	}
+
+	return err;
 }
 
 static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
 {
 	struct k_sigaction ka_copy;
 	siginfo_t info;
-	int sig;
+	int sig, handled_sig = 0;
 
-	sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL);
-	if(sig > 0){
+	while((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0){
+		handled_sig = 1;
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(regs, sig, &ka_copy, &info, oldset);
-		return(1);
+		if(!handle_signal(regs, sig, &ka_copy, &info, oldset))
+			break;
 	}
 
 	/* Did we come from a system call? */
-	if(PT_REGS_SYSCALL_NR(regs) >= 0){
+	if(!handled_sig && (PT_REGS_SYSCALL_NR(regs) >= 0)){
 		/* Restart the system call - no handlers present */
 		if(PT_REGS_SYSCALL_RET(regs) == -ERESTARTNOHAND ||
 		   PT_REGS_SYSCALL_RET(regs) == -ERESTARTSYS ||
@@ -134,7 +136,7 @@
 	if(current->ptrace & PT_DTRACE)
 		current->thread.singlestep_syscall =
 			is_syscall(PT_REGS_IP(&current->thread.regs));
-	return(0);
+	return(handled_sig);
 }
 
 int do_signal(void)


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

only message in thread, other threads:[~2004-11-12 23:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-13  2:01 [PATCH 10/11] - UML - Don't delay segfaults Jeff Dike

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

Powered by JetHome