diff options
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 7aaa51d8e5b8..3d09cf6cde75 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -680,23 +680,17 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) | |||
680 | * No need to set need_resched since signal event passing | 680 | * No need to set need_resched since signal event passing |
681 | * goes through ->blocked | 681 | * goes through ->blocked |
682 | */ | 682 | */ |
683 | void signal_wake_up(struct task_struct *t, int resume) | 683 | void signal_wake_up_state(struct task_struct *t, unsigned int state) |
684 | { | 684 | { |
685 | unsigned int mask; | ||
686 | |||
687 | set_tsk_thread_flag(t, TIF_SIGPENDING); | 685 | set_tsk_thread_flag(t, TIF_SIGPENDING); |
688 | |||
689 | /* | 686 | /* |
690 | * For SIGKILL, we want to wake it up in the stopped/traced/killable | 687 | * TASK_WAKEKILL also means wake it up in the stopped/traced/killable |
691 | * case. We don't check t->state here because there is a race with it | 688 | * case. We don't check t->state here because there is a race with it |
692 | * executing another processor and just now entering stopped state. | 689 | * executing another processor and just now entering stopped state. |
693 | * By using wake_up_state, we ensure the process will wake up and | 690 | * By using wake_up_state, we ensure the process will wake up and |
694 | * handle its death signal. | 691 | * handle its death signal. |
695 | */ | 692 | */ |
696 | mask = TASK_INTERRUPTIBLE; | 693 | if (!wake_up_state(t, state | TASK_INTERRUPTIBLE)) |
697 | if (resume) | ||
698 | mask |= TASK_WAKEKILL; | ||
699 | if (!wake_up_state(t, mask)) | ||
700 | kick_process(t); | 694 | kick_process(t); |
701 | } | 695 | } |
702 | 696 | ||
@@ -844,7 +838,7 @@ static void ptrace_trap_notify(struct task_struct *t) | |||
844 | assert_spin_locked(&t->sighand->siglock); | 838 | assert_spin_locked(&t->sighand->siglock); |
845 | 839 | ||
846 | task_set_jobctl_pending(t, JOBCTL_TRAP_NOTIFY); | 840 | task_set_jobctl_pending(t, JOBCTL_TRAP_NOTIFY); |
847 | signal_wake_up(t, t->jobctl & JOBCTL_LISTENING); | 841 | ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING); |
848 | } | 842 | } |
849 | 843 | ||
850 | /* | 844 | /* |
@@ -1800,6 +1794,10 @@ static inline int may_ptrace_stop(void) | |||
1800 | * If SIGKILL was already sent before the caller unlocked | 1794 | * If SIGKILL was already sent before the caller unlocked |
1801 | * ->siglock we must see ->core_state != NULL. Otherwise it | 1795 | * ->siglock we must see ->core_state != NULL. Otherwise it |
1802 | * is safe to enter schedule(). | 1796 | * is safe to enter schedule(). |
1797 | * | ||
1798 | * This is almost outdated, a task with the pending SIGKILL can't | ||
1799 | * block in TASK_TRACED. But PTRACE_EVENT_EXIT can be reported | ||
1800 | * after SIGKILL was already dequeued. | ||
1803 | */ | 1801 | */ |
1804 | if (unlikely(current->mm->core_state) && | 1802 | if (unlikely(current->mm->core_state) && |
1805 | unlikely(current->mm == current->parent->mm)) | 1803 | unlikely(current->mm == current->parent->mm)) |
@@ -1925,6 +1923,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info) | |||
1925 | if (gstop_done) | 1923 | if (gstop_done) |
1926 | do_notify_parent_cldstop(current, false, why); | 1924 | do_notify_parent_cldstop(current, false, why); |
1927 | 1925 | ||
1926 | /* tasklist protects us from ptrace_freeze_traced() */ | ||
1928 | __set_current_state(TASK_RUNNING); | 1927 | __set_current_state(TASK_RUNNING); |
1929 | if (clear_code) | 1928 | if (clear_code) |
1930 | current->exit_code = 0; | 1929 | current->exit_code = 0; |
@@ -2528,11 +2527,8 @@ static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset) | |||
2528 | */ | 2527 | */ |
2529 | void set_current_blocked(sigset_t *newset) | 2528 | void set_current_blocked(sigset_t *newset) |
2530 | { | 2529 | { |
2531 | struct task_struct *tsk = current; | ||
2532 | sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP)); | 2530 | sigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP)); |
2533 | spin_lock_irq(&tsk->sighand->siglock); | 2531 | __set_current_blocked(newset); |
2534 | __set_task_blocked(tsk, newset); | ||
2535 | spin_unlock_irq(&tsk->sighand->siglock); | ||
2536 | } | 2532 | } |
2537 | 2533 | ||
2538 | void __set_current_blocked(const sigset_t *newset) | 2534 | void __set_current_blocked(const sigset_t *newset) |
@@ -3119,8 +3115,9 @@ int __save_altstack(stack_t __user *uss, unsigned long sp) | |||
3119 | 3115 | ||
3120 | #ifdef CONFIG_COMPAT | 3116 | #ifdef CONFIG_COMPAT |
3121 | #ifdef CONFIG_GENERIC_SIGALTSTACK | 3117 | #ifdef CONFIG_GENERIC_SIGALTSTACK |
3122 | asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr, | 3118 | COMPAT_SYSCALL_DEFINE2(sigaltstack, |
3123 | compat_stack_t __user *uoss_ptr) | 3119 | const compat_stack_t __user *, uss_ptr, |
3120 | compat_stack_t __user *, uoss_ptr) | ||
3124 | { | 3121 | { |
3125 | stack_t uss, uoss; | 3122 | stack_t uss, uoss; |
3126 | int ret; | 3123 | int ret; |
@@ -3204,7 +3201,6 @@ SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, nset, | |||
3204 | if (nset) { | 3201 | if (nset) { |
3205 | if (copy_from_user(&new_set, nset, sizeof(*nset))) | 3202 | if (copy_from_user(&new_set, nset, sizeof(*nset))) |
3206 | return -EFAULT; | 3203 | return -EFAULT; |
3207 | new_set &= ~(sigmask(SIGKILL) | sigmask(SIGSTOP)); | ||
3208 | 3204 | ||
3209 | new_blocked = current->blocked; | 3205 | new_blocked = current->blocked; |
3210 | 3206 | ||
@@ -3222,7 +3218,7 @@ SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, nset, | |||
3222 | return -EINVAL; | 3218 | return -EINVAL; |
3223 | } | 3219 | } |
3224 | 3220 | ||
3225 | __set_current_blocked(&new_blocked); | 3221 | set_current_blocked(&new_blocked); |
3226 | } | 3222 | } |
3227 | 3223 | ||
3228 | if (oset) { | 3224 | if (oset) { |
@@ -3286,6 +3282,7 @@ SYSCALL_DEFINE1(ssetmask, int, newmask) | |||
3286 | int old = current->blocked.sig[0]; | 3282 | int old = current->blocked.sig[0]; |
3287 | sigset_t newset; | 3283 | sigset_t newset; |
3288 | 3284 | ||
3285 | siginitset(&newset, newmask); | ||
3289 | set_current_blocked(&newset); | 3286 | set_current_blocked(&newset); |
3290 | 3287 | ||
3291 | return old; | 3288 | return old; |