Commit f89e6c90 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: Don't delay segfaults

From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>

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: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 44383059
...@@ -38,7 +38,7 @@ EXPORT_SYMBOL(unblock_signals); ...@@ -38,7 +38,7 @@ EXPORT_SYMBOL(unblock_signals);
/* /*
* OK, we're invoking a handler * OK, we're invoking a handler
*/ */
static void handle_signal(struct pt_regs *regs, unsigned long signr, static int handle_signal(struct pt_regs *regs, unsigned long signr,
struct k_sigaction *ka, siginfo_t *info, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset) sigset_t *oldset)
{ {
...@@ -94,23 +94,25 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr, ...@@ -94,23 +94,25 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
recalc_sigpending(); recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock); spin_unlock_irq(&current->sighand->siglock);
} }
return err;
} }
static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset) static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
{ {
struct k_sigaction ka_copy; struct k_sigaction ka_copy;
siginfo_t info; siginfo_t info;
int sig; int sig, handled_sig = 0;
sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL); while((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0){
if(sig > 0){ handled_sig = 1;
/* Whee! Actually deliver the signal. */ /* Whee! Actually deliver the signal. */
handle_signal(regs, sig, &ka_copy, &info, oldset); if(!handle_signal(regs, sig, &ka_copy, &info, oldset))
return(1); break;
} }
/* Did we come from a system call? */ /* 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 */ /* Restart the system call - no handlers present */
if(PT_REGS_SYSCALL_RET(regs) == -ERESTARTNOHAND || if(PT_REGS_SYSCALL_RET(regs) == -ERESTARTNOHAND ||
PT_REGS_SYSCALL_RET(regs) == -ERESTARTSYS || PT_REGS_SYSCALL_RET(regs) == -ERESTARTSYS ||
...@@ -134,7 +136,7 @@ static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset) ...@@ -134,7 +136,7 @@ static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
if(current->ptrace & PT_DTRACE) if(current->ptrace & PT_DTRACE)
current->thread.singlestep_syscall = current->thread.singlestep_syscall =
is_syscall(PT_REGS_IP(&current->thread.regs)); is_syscall(PT_REGS_IP(&current->thread.regs));
return(0); return(handled_sig);
} }
int do_signal(void) int do_signal(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment