2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
|
|
* Copyright (C) 1994 - 2000 Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/config.h>
|
2005-06-15 15:00:12 +02:00
|
|
|
#include <linux/cache.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/personality.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/smp_lock.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
2005-05-31 13:49:19 +02:00
|
|
|
#include <asm/abi.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/asm.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/fpu.h>
|
|
|
|
#include <asm/sim.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/ucontext.h>
|
|
|
|
#include <asm/cpu-features.h>
|
2005-06-15 15:00:12 +02:00
|
|
|
#include <asm/war.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include "signal-common.h"
|
|
|
|
|
|
|
|
#define DEBUG_SIG 0
|
|
|
|
|
|
|
|
#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
|
|
|
|
|
2005-05-31 13:49:19 +02:00
|
|
|
int do_signal(sigset_t *oldset, struct pt_regs *regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Atomically swap in the new signal mask, and wait for a signal.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
|
|
|
save_static_function(sys_sigsuspend);
|
|
|
|
__attribute_used__ noinline static int
|
|
|
|
_sys_sigsuspend(nabi_no_regargs struct pt_regs regs)
|
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
sigset_t saveset, newset;
|
|
|
|
sigset_t __user *uset;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
uset = (sigset_t __user *) regs.regs[4];
|
2005-04-17 00:20:36 +02:00
|
|
|
if (copy_from_user(&newset, uset, sizeof(sigset_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
sigdelsetmask(&newset, ~_BLOCKABLE);
|
|
|
|
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
saveset = current->blocked;
|
|
|
|
current->blocked = newset;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
|
|
|
regs.regs[2] = EINTR;
|
|
|
|
regs.regs[7] = 1;
|
|
|
|
while (1) {
|
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
schedule();
|
|
|
|
if (do_signal(&saveset, ®s))
|
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
save_static_function(sys_rt_sigsuspend);
|
|
|
|
__attribute_used__ noinline static int
|
|
|
|
_sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
|
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
sigset_t saveset, newset;
|
|
|
|
sigset_t __user *unewset;
|
2005-04-17 00:20:36 +02:00
|
|
|
size_t sigsetsize;
|
|
|
|
|
|
|
|
/* XXX Don't preclude handling different sized sigset_t's. */
|
|
|
|
sigsetsize = regs.regs[5];
|
|
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2005-03-01 20:22:29 +01:00
|
|
|
unewset = (sigset_t __user *) regs.regs[4];
|
2005-04-17 00:20:36 +02:00
|
|
|
if (copy_from_user(&newset, unewset, sizeof(newset)))
|
|
|
|
return -EFAULT;
|
|
|
|
sigdelsetmask(&newset, ~_BLOCKABLE);
|
|
|
|
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
saveset = current->blocked;
|
|
|
|
current->blocked = newset;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
|
|
|
regs.regs[2] = EINTR;
|
|
|
|
regs.regs[7] = 1;
|
|
|
|
while (1) {
|
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
schedule();
|
|
|
|
if (do_signal(&saveset, ®s))
|
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
|
|
|
asmlinkage int sys_sigaction(int sig, const struct sigaction *act,
|
|
|
|
struct sigaction *oact)
|
|
|
|
{
|
|
|
|
struct k_sigaction new_ka, old_ka;
|
|
|
|
int ret;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (act) {
|
|
|
|
old_sigset_t mask;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_READ, act, sizeof(*act)))
|
|
|
|
return -EFAULT;
|
|
|
|
err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
|
|
|
|
err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
|
|
|
|
err |= __get_user(mask, &act->sa_mask.sig[0]);
|
|
|
|
if (err)
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
siginitset(&new_ka.sa.sa_mask, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
|
|
|
|
|
|
if (!ret && oact) {
|
|
|
|
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
|
|
|
|
return -EFAULT;
|
|
|
|
err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
|
|
|
|
err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
|
|
|
|
err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
|
|
|
|
err |= __put_user(0, &oact->sa_mask.sig[1]);
|
|
|
|
err |= __put_user(0, &oact->sa_mask.sig[2]);
|
|
|
|
err |= __put_user(0, &oact->sa_mask.sig[3]);
|
|
|
|
if (err)
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
asmlinkage int sys_sigaltstack(nabi_no_regargs struct pt_regs regs)
|
|
|
|
{
|
2005-03-01 20:22:29 +01:00
|
|
|
const stack_t __user *uss = (const stack_t __user *) regs.regs[4];
|
|
|
|
stack_t __user *uoss = (stack_t __user *) regs.regs[5];
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long usp = regs.regs[29];
|
|
|
|
|
|
|
|
return do_sigaltstack(uss, uoss, usp);
|
|
|
|
}
|
|
|
|
|
2005-06-15 15:00:12 +02:00
|
|
|
/*
|
|
|
|
* Horribly complicated - with the bloody RM9000 workarounds enabled
|
|
|
|
* the signal trampolines is moving to the end of the structure so we can
|
|
|
|
* increase the alignment without breaking software compatibility.
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
|
|
|
struct sigframe {
|
|
|
|
u32 sf_ass[4]; /* argument save space for o32 */
|
2005-06-15 15:00:12 +02:00
|
|
|
#if ICACHE_REFILLS_WORKAROUND_WAR
|
|
|
|
u32 sf_pad[2];
|
|
|
|
#else
|
|
|
|
u32 sf_code[2]; /* signal trampoline */
|
|
|
|
#endif
|
|
|
|
struct sigcontext sf_sc;
|
2005-04-17 00:20:36 +02:00
|
|
|
sigset_t sf_mask;
|
2005-06-15 15:00:12 +02:00
|
|
|
#if ICACHE_REFILLS_WORKAROUND_WAR
|
|
|
|
u32 sf_code[8] ____cacheline_aligned; /* signal trampoline */
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct rt_sigframe {
|
|
|
|
u32 rs_ass[4]; /* argument save space for o32 */
|
2005-06-15 15:00:12 +02:00
|
|
|
#if ICACHE_REFILLS_WORKAROUND_WAR
|
|
|
|
u32 rs_pad[2];
|
|
|
|
#else
|
|
|
|
u32 rs_code[2]; /* signal trampoline */
|
|
|
|
#endif
|
|
|
|
struct siginfo rs_info;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct ucontext rs_uc;
|
2005-06-15 15:00:12 +02:00
|
|
|
#if ICACHE_REFILLS_WORKAROUND_WAR
|
|
|
|
u32 rs_code[8] ____cacheline_aligned; /* signal trampoline */
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
|
|
|
save_static_function(sys_sigreturn);
|
|
|
|
__attribute_used__ noinline static void
|
|
|
|
_sys_sigreturn(nabi_no_regargs struct pt_regs regs)
|
|
|
|
{
|
|
|
|
struct sigframe *frame;
|
|
|
|
sigset_t blocked;
|
|
|
|
|
|
|
|
frame = (struct sigframe *) regs.regs[29];
|
|
|
|
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
|
|
|
|
goto badframe;
|
|
|
|
if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
sigdelsetmask(&blocked, ~_BLOCKABLE);
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
current->blocked = blocked;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
|
|
|
if (restore_sigcontext(®s, &frame->sf_sc))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't let your children do this ...
|
|
|
|
*/
|
|
|
|
if (current_thread_info()->flags & TIF_SYSCALL_TRACE)
|
|
|
|
do_syscall_trace(®s, 1);
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"move\t$29, %0\n\t"
|
|
|
|
"j\tsyscall_exit"
|
|
|
|
:/* no outputs */
|
|
|
|
:"r" (®s));
|
|
|
|
/* Unreached */
|
|
|
|
|
|
|
|
badframe:
|
|
|
|
force_sig(SIGSEGV, current);
|
|
|
|
}
|
2005-05-31 13:49:19 +02:00
|
|
|
#endif /* CONFIG_TRAD_SIGNALS */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
save_static_function(sys_rt_sigreturn);
|
|
|
|
__attribute_used__ noinline static void
|
|
|
|
_sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
|
|
|
|
{
|
|
|
|
struct rt_sigframe *frame;
|
|
|
|
sigset_t set;
|
|
|
|
stack_t st;
|
|
|
|
|
|
|
|
frame = (struct rt_sigframe *) regs.regs[29];
|
|
|
|
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
|
|
|
|
goto badframe;
|
|
|
|
if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
sigdelsetmask(&set, ~_BLOCKABLE);
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
current->blocked = set;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
|
|
|
if (restore_sigcontext(®s, &frame->rs_uc.uc_mcontext))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st)))
|
|
|
|
goto badframe;
|
|
|
|
/* It is more difficult to avoid calling this function than to
|
|
|
|
call it and ignore errors. */
|
|
|
|
do_sigaltstack(&st, NULL, regs.regs[29]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't let your children do this ...
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"move\t$29, %0\n\t"
|
|
|
|
"j\tsyscall_exit"
|
|
|
|
:/* no outputs */
|
|
|
|
:"r" (®s));
|
|
|
|
/* Unreached */
|
|
|
|
|
|
|
|
badframe:
|
|
|
|
force_sig(SIGSEGV, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
2005-05-31 13:49:19 +02:00
|
|
|
void setup_frame(struct k_sigaction * ka, struct pt_regs *regs,
|
2005-04-17 00:20:36 +02:00
|
|
|
int signr, sigset_t *set)
|
|
|
|
{
|
|
|
|
struct sigframe *frame;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
frame = get_sigframe(ka, regs, sizeof(*frame));
|
|
|
|
if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
2005-06-15 15:00:12 +02:00
|
|
|
install_sigtramp(frame->sf_code, __NR_sigreturn);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
err |= setup_sigcontext(regs, &frame->sf_sc);
|
|
|
|
err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
|
|
|
|
if (err)
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Arguments to signal handler:
|
|
|
|
*
|
|
|
|
* a0 = signal number
|
|
|
|
* a1 = 0 (should be cause)
|
|
|
|
* a2 = pointer to struct sigcontext
|
|
|
|
*
|
|
|
|
* $25 and c0_epc point to the signal handler, $29 points to the
|
|
|
|
* struct sigframe.
|
|
|
|
*/
|
|
|
|
regs->regs[ 4] = signr;
|
|
|
|
regs->regs[ 5] = 0;
|
|
|
|
regs->regs[ 6] = (unsigned long) &frame->sf_sc;
|
|
|
|
regs->regs[29] = (unsigned long) frame;
|
|
|
|
regs->regs[31] = (unsigned long) frame->sf_code;
|
|
|
|
regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
|
|
|
|
|
|
|
|
#if DEBUG_SIG
|
|
|
|
printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
|
|
|
|
current->comm, current->pid,
|
|
|
|
frame, regs->cp0_epc, frame->regs[31]);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
|
|
|
|
give_sigsegv:
|
|
|
|
force_sigsegv(signr, current);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-05-31 13:49:19 +02:00
|
|
|
void setup_rt_frame(struct k_sigaction * ka, struct pt_regs *regs,
|
2005-04-17 00:20:36 +02:00
|
|
|
int signr, sigset_t *set, siginfo_t *info)
|
|
|
|
{
|
|
|
|
struct rt_sigframe *frame;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
frame = get_sigframe(ka, regs, sizeof(*frame));
|
|
|
|
if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
2005-06-15 15:00:12 +02:00
|
|
|
install_sigtramp(frame->rs_code, __NR_rt_sigreturn);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Create siginfo. */
|
|
|
|
err |= copy_siginfo_to_user(&frame->rs_info, info);
|
|
|
|
|
|
|
|
/* Create the ucontext. */
|
|
|
|
err |= __put_user(0, &frame->rs_uc.uc_flags);
|
|
|
|
err |= __put_user(0, &frame->rs_uc.uc_link);
|
|
|
|
err |= __put_user((void *)current->sas_ss_sp,
|
|
|
|
&frame->rs_uc.uc_stack.ss_sp);
|
|
|
|
err |= __put_user(sas_ss_flags(regs->regs[29]),
|
|
|
|
&frame->rs_uc.uc_stack.ss_flags);
|
|
|
|
err |= __put_user(current->sas_ss_size,
|
|
|
|
&frame->rs_uc.uc_stack.ss_size);
|
|
|
|
err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
|
|
|
|
err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Arguments to signal handler:
|
|
|
|
*
|
|
|
|
* a0 = signal number
|
|
|
|
* a1 = 0 (should be cause)
|
|
|
|
* a2 = pointer to ucontext
|
|
|
|
*
|
|
|
|
* $25 and c0_epc point to the signal handler, $29 points to
|
|
|
|
* the struct rt_sigframe.
|
|
|
|
*/
|
|
|
|
regs->regs[ 4] = signr;
|
|
|
|
regs->regs[ 5] = (unsigned long) &frame->rs_info;
|
|
|
|
regs->regs[ 6] = (unsigned long) &frame->rs_uc;
|
|
|
|
regs->regs[29] = (unsigned long) frame;
|
|
|
|
regs->regs[31] = (unsigned long) frame->rs_code;
|
|
|
|
regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
|
|
|
|
|
|
|
|
#if DEBUG_SIG
|
|
|
|
printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
|
|
|
|
current->comm, current->pid,
|
|
|
|
frame, regs->cp0_epc, regs->regs[31]);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
|
|
|
|
give_sigsegv:
|
|
|
|
force_sigsegv(signr, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void setup_rt_frame_n32(struct k_sigaction * ka,
|
|
|
|
struct pt_regs *regs, int signr, sigset_t *set, siginfo_t *info);
|
|
|
|
|
|
|
|
static inline void handle_signal(unsigned long sig, siginfo_t *info,
|
|
|
|
struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
switch(regs->regs[0]) {
|
|
|
|
case ERESTART_RESTARTBLOCK:
|
|
|
|
case ERESTARTNOHAND:
|
|
|
|
regs->regs[2] = EINTR;
|
|
|
|
break;
|
|
|
|
case ERESTARTSYS:
|
|
|
|
if(!(ka->sa.sa_flags & SA_RESTART)) {
|
|
|
|
regs->regs[2] = EINTR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
case ERESTARTNOINTR: /* Userland will reload $v0. */
|
|
|
|
regs->regs[7] = regs->regs[26];
|
|
|
|
regs->cp0_epc -= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
regs->regs[0] = 0; /* Don't deal with this again. */
|
|
|
|
|
2005-05-31 13:49:19 +02:00
|
|
|
if (sig_uses_siginfo(ka))
|
|
|
|
current->thread.abi->setup_rt_frame(ka, regs, sig, oldset, info);
|
2005-04-17 00:20:36 +02:00
|
|
|
else
|
2005-05-31 13:49:19 +02:00
|
|
|
current->thread.abi->setup_frame(ka, regs, sig, oldset);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 17:44:09 +02:00
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
|
|
|
|
if (!(ka->sa.sa_flags & SA_NODEFER))
|
2005-04-17 00:20:36 +02:00
|
|
|
sigaddset(¤t->blocked,sig);
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 17:44:09 +02:00
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-05-31 13:49:19 +02:00
|
|
|
int do_signal(sigset_t *oldset, struct pt_regs *regs)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct k_sigaction ka;
|
|
|
|
siginfo_t info;
|
|
|
|
int signr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want the common case to go fast, which is why we may in certain
|
|
|
|
* cases get here from kernel mode. Just return without doing anything
|
|
|
|
* if so.
|
|
|
|
*/
|
|
|
|
if (!user_mode(regs))
|
|
|
|
return 1;
|
|
|
|
|
2005-06-27 23:36:30 +02:00
|
|
|
if (try_to_freeze())
|
2005-04-17 00:20:36 +02:00
|
|
|
goto no_signal;
|
|
|
|
|
|
|
|
if (!oldset)
|
|
|
|
oldset = ¤t->blocked;
|
|
|
|
|
|
|
|
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
|
|
|
|
if (signr > 0) {
|
|
|
|
handle_signal(signr, &info, &ka, oldset, regs);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
no_signal:
|
|
|
|
/*
|
|
|
|
* Who's code doesn't conform to the restartable syscall convention
|
|
|
|
* dies here!!! The li instruction, a single machine instruction,
|
|
|
|
* must directly be followed by the syscall instruction.
|
|
|
|
*/
|
|
|
|
if (regs->regs[0]) {
|
|
|
|
if (regs->regs[2] == ERESTARTNOHAND ||
|
|
|
|
regs->regs[2] == ERESTARTSYS ||
|
|
|
|
regs->regs[2] == ERESTARTNOINTR) {
|
|
|
|
regs->regs[7] = regs->regs[26];
|
|
|
|
regs->cp0_epc -= 8;
|
|
|
|
}
|
|
|
|
if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
|
|
|
|
regs->regs[2] = __NR_restart_syscall;
|
|
|
|
regs->regs[7] = regs->regs[26];
|
|
|
|
regs->cp0_epc -= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* notification of userspace execution resumption
|
|
|
|
* - triggered by current->work.notify_resume
|
|
|
|
*/
|
|
|
|
asmlinkage void do_notify_resume(struct pt_regs *regs, sigset_t *oldset,
|
|
|
|
__u32 thread_info_flags)
|
|
|
|
{
|
|
|
|
/* deal with pending signal delivery */
|
|
|
|
if (thread_info_flags & _TIF_SIGPENDING) {
|
2005-05-31 13:49:19 +02:00
|
|
|
current->thread.abi->do_signal(oldset, regs);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|