mirror of https://gitee.com/openkylin/linux.git
Merge branch 'x86-signal-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-signal-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86: Kill handle_signal()->set_fs() x86, do_signal: Simplify the TS_RESTORE_SIGMASK logic x86, signals: Convert the X86_32 code to use set_current_blocked() x86, signals: Convert the IA32_EMULATION code to use set_current_blocked()
This commit is contained in:
commit
8051207959
|
@ -127,15 +127,17 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
|
||||||
|
|
||||||
asmlinkage long sys32_sigsuspend(int history0, int history1, old_sigset_t mask)
|
asmlinkage long sys32_sigsuspend(int history0, int history1, old_sigset_t mask)
|
||||||
{
|
{
|
||||||
mask &= _BLOCKABLE;
|
sigset_t blocked;
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
|
||||||
current->saved_sigmask = current->blocked;
|
current->saved_sigmask = current->blocked;
|
||||||
siginitset(¤t->blocked, mask);
|
|
||||||
recalc_sigpending();
|
mask &= _BLOCKABLE;
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
siginitset(&blocked, mask);
|
||||||
|
set_current_blocked(&blocked);
|
||||||
|
|
||||||
current->state = TASK_INTERRUPTIBLE;
|
current->state = TASK_INTERRUPTIBLE;
|
||||||
schedule();
|
schedule();
|
||||||
|
|
||||||
set_restore_sigmask();
|
set_restore_sigmask();
|
||||||
return -ERESTARTNOHAND;
|
return -ERESTARTNOHAND;
|
||||||
}
|
}
|
||||||
|
@ -279,10 +281,7 @@ asmlinkage long sys32_sigreturn(struct pt_regs *regs)
|
||||||
goto badframe;
|
goto badframe;
|
||||||
|
|
||||||
sigdelsetmask(&set, ~_BLOCKABLE);
|
sigdelsetmask(&set, ~_BLOCKABLE);
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
set_current_blocked(&set);
|
||||||
current->blocked = set;
|
|
||||||
recalc_sigpending();
|
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
|
||||||
|
|
||||||
if (ia32_restore_sigcontext(regs, &frame->sc, &ax))
|
if (ia32_restore_sigcontext(regs, &frame->sc, &ax))
|
||||||
goto badframe;
|
goto badframe;
|
||||||
|
@ -308,10 +307,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs)
|
||||||
goto badframe;
|
goto badframe;
|
||||||
|
|
||||||
sigdelsetmask(&set, ~_BLOCKABLE);
|
sigdelsetmask(&set, ~_BLOCKABLE);
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
set_current_blocked(&set);
|
||||||
current->blocked = set;
|
|
||||||
recalc_sigpending();
|
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
|
||||||
|
|
||||||
if (ia32_restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
|
if (ia32_restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
|
||||||
goto badframe;
|
goto badframe;
|
||||||
|
|
|
@ -485,17 +485,18 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
|
||||||
asmlinkage int
|
asmlinkage int
|
||||||
sys_sigsuspend(int history0, int history1, old_sigset_t mask)
|
sys_sigsuspend(int history0, int history1, old_sigset_t mask)
|
||||||
{
|
{
|
||||||
mask &= _BLOCKABLE;
|
sigset_t blocked;
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
|
||||||
current->saved_sigmask = current->blocked;
|
current->saved_sigmask = current->blocked;
|
||||||
siginitset(¤t->blocked, mask);
|
|
||||||
recalc_sigpending();
|
mask &= _BLOCKABLE;
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
siginitset(&blocked, mask);
|
||||||
|
set_current_blocked(&blocked);
|
||||||
|
|
||||||
current->state = TASK_INTERRUPTIBLE;
|
current->state = TASK_INTERRUPTIBLE;
|
||||||
schedule();
|
schedule();
|
||||||
set_restore_sigmask();
|
|
||||||
|
|
||||||
|
set_restore_sigmask();
|
||||||
return -ERESTARTNOHAND;
|
return -ERESTARTNOHAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,10 +573,7 @@ unsigned long sys_sigreturn(struct pt_regs *regs)
|
||||||
goto badframe;
|
goto badframe;
|
||||||
|
|
||||||
sigdelsetmask(&set, ~_BLOCKABLE);
|
sigdelsetmask(&set, ~_BLOCKABLE);
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
set_current_blocked(&set);
|
||||||
current->blocked = set;
|
|
||||||
recalc_sigpending();
|
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
|
||||||
|
|
||||||
if (restore_sigcontext(regs, &frame->sc, &ax))
|
if (restore_sigcontext(regs, &frame->sc, &ax))
|
||||||
goto badframe;
|
goto badframe;
|
||||||
|
@ -653,11 +651,15 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
|
||||||
|
|
||||||
static int
|
static int
|
||||||
setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
|
setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
|
||||||
sigset_t *set, struct pt_regs *regs)
|
struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
int usig = signr_convert(sig);
|
int usig = signr_convert(sig);
|
||||||
|
sigset_t *set = ¤t->blocked;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
|
||||||
|
set = ¤t->saved_sigmask;
|
||||||
|
|
||||||
/* Set up the stack frame */
|
/* Set up the stack frame */
|
||||||
if (is_ia32) {
|
if (is_ia32) {
|
||||||
if (ka->sa.sa_flags & SA_SIGINFO)
|
if (ka->sa.sa_flags & SA_SIGINFO)
|
||||||
|
@ -672,12 +674,13 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
||||||
sigset_t *oldset, struct pt_regs *regs)
|
struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
sigset_t blocked;
|
sigset_t blocked;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -712,20 +715,11 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
|
||||||
likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
|
likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
|
||||||
regs->flags &= ~X86_EFLAGS_TF;
|
regs->flags &= ~X86_EFLAGS_TF;
|
||||||
|
|
||||||
ret = setup_rt_frame(sig, ka, info, oldset, regs);
|
ret = setup_rt_frame(sig, ka, info, regs);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
#ifdef CONFIG_X86_64
|
|
||||||
/*
|
|
||||||
* This has nothing to do with segment registers,
|
|
||||||
* despite the name. This magic affects uaccess.h
|
|
||||||
* macros' behavior. Reset it to the normal setting.
|
|
||||||
*/
|
|
||||||
set_fs(USER_DS);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clear the direction flag as per the ABI for function entry.
|
* Clear the direction flag as per the ABI for function entry.
|
||||||
*/
|
*/
|
||||||
|
@ -767,7 +761,6 @@ static void do_signal(struct pt_regs *regs)
|
||||||
struct k_sigaction ka;
|
struct k_sigaction ka;
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
int signr;
|
int signr;
|
||||||
sigset_t *oldset;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We want the common case to go fast, which is why we may in certain
|
* We want the common case to go fast, which is why we may in certain
|
||||||
|
@ -779,23 +772,10 @@ static void do_signal(struct pt_regs *regs)
|
||||||
if (!user_mode(regs))
|
if (!user_mode(regs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (current_thread_info()->status & TS_RESTORE_SIGMASK)
|
|
||||||
oldset = ¤t->saved_sigmask;
|
|
||||||
else
|
|
||||||
oldset = ¤t->blocked;
|
|
||||||
|
|
||||||
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
|
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
|
||||||
if (signr > 0) {
|
if (signr > 0) {
|
||||||
/* Whee! Actually deliver the signal. */
|
/* Whee! Actually deliver the signal. */
|
||||||
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
|
handle_signal(signr, &info, &ka, regs);
|
||||||
/*
|
|
||||||
* A signal was successfully delivered; the saved
|
|
||||||
* sigmask will have been stored in the signal frame,
|
|
||||||
* and will be restored by sigreturn, so we can simply
|
|
||||||
* clear the TS_RESTORE_SIGMASK flag.
|
|
||||||
*/
|
|
||||||
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,7 +803,7 @@ static void do_signal(struct pt_regs *regs)
|
||||||
*/
|
*/
|
||||||
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
|
if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
|
||||||
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
|
current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
|
||||||
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
|
set_current_blocked(¤t->saved_sigmask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue