Commit 431a4c7b authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: signal bug fix

This patch fixes a bug introduced in the last batch of signal fixes.  The
system call return value should only be reset if called diectly from a
system call, i.e.  sigsuspend.  The fixes added earlier caused any
interrupted non-zero system call return to be reset, confusing fork and
vfork, among others.
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 9872895c
......@@ -40,19 +40,19 @@ EXPORT_SYMBOL(unblock_signals);
*/
static void handle_signal(struct pt_regs *regs, unsigned long signr,
struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset)
sigset_t *oldset, int error)
{
__sighandler_t handler;
void (*restorer)(void);
unsigned long sp;
sigset_t save;
int error, err, ret;
int err, ret;
error = PT_REGS_SYSCALL_RET(&current->thread.regs);
err = PT_REGS_SYSCALL_RET(&current->thread.regs);
ret = 0;
/* Always make any pending restarted system calls return -EINTR */
current_thread_info()->restart_block.fn = do_no_restart_syscall;
switch(error){
switch(err){
case -ERESTART_RESTARTBLOCK:
case -ERESTARTNOHAND:
ret = -EINTR;
......@@ -99,7 +99,8 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
if((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(sp) == 0))
sp = current->sas_ss_sp + current->sas_ss_size;
if(error != 0) PT_REGS_SET_SYSCALL_RETURN(regs, ret);
if(error != 0)
PT_REGS_SET_SYSCALL_RETURN(regs, ret);
if (ka->sa.sa_flags & SA_RESTORER) restorer = ka->sa.sa_restorer;
else restorer = NULL;
......@@ -114,7 +115,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
force_sigsegv(signr, current);
}
static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset, int error)
{
struct k_sigaction ka_copy;
siginfo_t info;
......@@ -126,7 +127,7 @@ static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL);
if(sig > 0){
/* Whee! Actually deliver the signal. */
handle_signal(regs, sig, &ka_copy, &info, oldset);
handle_signal(regs, sig, &ka_copy, &info, oldset, error);
return(1);
}
......@@ -160,7 +161,7 @@ static int kern_do_signal(struct pt_regs *regs, sigset_t *oldset)
int do_signal(int error)
{
return(kern_do_signal(&current->thread.regs, NULL));
return(kern_do_signal(&current->thread.regs, NULL, error));
}
/*
......@@ -181,7 +182,7 @@ int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if(kern_do_signal(&current->thread.regs, &saveset))
if(kern_do_signal(&current->thread.regs, &saveset, -EINTR))
return(-EINTR);
}
}
......@@ -208,7 +209,7 @@ int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (kern_do_signal(&current->thread.regs, &saveset))
if (kern_do_signal(&current->thread.regs, &saveset, -EINTR))
return(-EINTR);
}
}
......
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