Lines Matching +full:south +full:- +full:field

1 // SPDX-License-Identifier: GPL-2.0-only
7 * 1997-11-02 Modified for POSIX.1b signals by Richard Henderson
9 * 2003-06-02 Jim Houston - Concurrent Computer Corp.
46 #include <linux/posix-timers.h>
72 return t->sighand->action[sig - 1].sa.sa_handler; in sig_handler()
92 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && in sig_task_ignored()
97 if (unlikely((t->flags & PF_KTHREAD) && in sig_task_ignored()
111 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) in sig_ignored()
119 if (t->ptrace && sig != SIGKILL) in sig_ignored()
126 * Re-calculate pending state from the set of locally pending
136 for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;) in has_pending_signals()
137 ready |= signal->sig[i] &~ blocked->sig[i]; in has_pending_signals()
140 case 4: ready = signal->sig[3] &~ blocked->sig[3]; in has_pending_signals()
141 ready |= signal->sig[2] &~ blocked->sig[2]; in has_pending_signals()
142 ready |= signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
143 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
146 case 2: ready = signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
147 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
150 case 1: ready = signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
155 #define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
159 if ((t->jobctl & (JOBCTL_PENDING_MASK | JOBCTL_TRAP_FREEZE)) || in recalc_sigpending_tsk()
160 PENDING(&t->pending, &t->blocked) || in recalc_sigpending_tsk()
161 PENDING(&t->signal->shared_pending, &t->blocked) || in recalc_sigpending_tsk()
169 * when it's possible the current syscall is returning -ERESTART*. in recalc_sigpending_tsk()
188 spin_lock_irq(&current->sighand->siglock); in calculate_sigpending()
191 spin_unlock_irq(&current->sighand->siglock); in calculate_sigpending()
205 s = pending->signal.sig; in next_signal()
206 m = mask->sig; in next_signal()
257 current->comm, current->pid, sig); in print_dropped_signal()
261 * task_set_jobctl_pending - set jobctl pending bits
265 * Clear @mask from @task->jobctl. @mask must be subset of
272 * Must be called with @task->sighand->siglock held.
283 if (unlikely(fatal_signal_pending(task) || (task->flags & PF_EXITING))) in task_set_jobctl_pending()
287 task->jobctl &= ~JOBCTL_STOP_SIGMASK; in task_set_jobctl_pending()
289 task->jobctl |= mask; in task_set_jobctl_pending()
294 * task_clear_jobctl_trapping - clear jobctl trapping bit
299 * locking. @task->siglock guarantees that @task->parent points to the
303 * Must be called with @task->sighand->siglock held.
307 if (unlikely(task->jobctl & JOBCTL_TRAPPING)) { in task_clear_jobctl_trapping()
308 task->jobctl &= ~JOBCTL_TRAPPING; in task_clear_jobctl_trapping()
310 wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT); in task_clear_jobctl_trapping()
315 * task_clear_jobctl_pending - clear jobctl pending bits
319 * Clear @mask from @task->jobctl. @mask must be subset of
327 * Must be called with @task->sighand->siglock held.
336 task->jobctl &= ~mask; in task_clear_jobctl_pending()
338 if (!(task->jobctl & JOBCTL_PENDING_MASK)) in task_clear_jobctl_pending()
343 * task_participate_group_stop - participate in a group stop
352 * Must be called with @task->sighand->siglock held.
360 struct signal_struct *sig = task->signal; in task_participate_group_stop()
361 bool consume = task->jobctl & JOBCTL_STOP_CONSUME; in task_participate_group_stop()
363 WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING)); in task_participate_group_stop()
370 if (!WARN_ON_ONCE(sig->group_stop_count == 0)) in task_participate_group_stop()
371 sig->group_stop_count--; in task_participate_group_stop()
377 if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) { in task_participate_group_stop()
386 unsigned long mask = current->jobctl & JOBCTL_STOP_SIGMASK; in task_join_group_stop()
387 struct signal_struct *sig = current->signal; in task_join_group_stop()
389 if (sig->group_stop_count) { in task_join_group_stop()
390 sig->group_stop_count++; in task_join_group_stop()
392 } else if (!(sig->flags & SIGNAL_STOP_STOPPED)) in task_join_group_stop()
395 /* Have the new thread join an on-going signal group stop */ in task_join_group_stop()
401 * - this may be called without locks if and only if t == current, otherwise an
437 INIT_LIST_HEAD(&q->list); in __sigqueue_alloc()
438 q->flags = sigqueue_flags; in __sigqueue_alloc()
439 q->ucounts = ucounts; in __sigqueue_alloc()
446 if (q->flags & SIGQUEUE_PREALLOC) in __sigqueue_free()
448 if (q->ucounts) { in __sigqueue_free()
449 dec_rlimit_put_ucounts(q->ucounts, UCOUNT_RLIMIT_SIGPENDING); in __sigqueue_free()
450 q->ucounts = NULL; in __sigqueue_free()
459 sigemptyset(&queue->signal); in flush_sigqueue()
460 while (!list_empty(&queue->list)) { in flush_sigqueue()
461 q = list_entry(queue->list.next, struct sigqueue , list); in flush_sigqueue()
462 list_del_init(&q->list); in flush_sigqueue()
474 spin_lock_irqsave(&t->sighand->siglock, flags); in flush_signals()
476 flush_sigqueue(&t->pending); in flush_signals()
477 flush_sigqueue(&t->signal->shared_pending); in flush_signals()
478 spin_unlock_irqrestore(&t->sighand->siglock, flags); in flush_signals()
488 signal = pending->signal; in __flush_itimer_signals()
491 list_for_each_entry_safe(q, n, &pending->list, list) { in __flush_itimer_signals()
492 int sig = q->info.si_signo; in __flush_itimer_signals()
494 if (likely(q->info.si_code != SI_TIMER)) { in __flush_itimer_signals()
498 list_del_init(&q->list); in __flush_itimer_signals()
503 sigorsets(&pending->signal, &signal, &retain); in __flush_itimer_signals()
511 spin_lock_irqsave(&tsk->sighand->siglock, flags); in flush_itimer_signals()
512 __flush_itimer_signals(&tsk->pending); in flush_itimer_signals()
513 __flush_itimer_signals(&tsk->signal->shared_pending); in flush_itimer_signals()
514 spin_unlock_irqrestore(&tsk->sighand->siglock, flags); in flush_itimer_signals()
523 t->sighand->action[i].sa.sa_handler = SIG_IGN; in ignore_signals()
536 struct k_sigaction *ka = &t->sighand->action[0]; in flush_signal_handlers()
537 for (i = _NSIG ; i != 0 ; i--) { in flush_signal_handlers()
538 if (force_default || ka->sa.sa_handler != SIG_IGN) in flush_signal_handlers()
539 ka->sa.sa_handler = SIG_DFL; in flush_signal_handlers()
540 ka->sa.sa_flags = 0; in flush_signal_handlers()
542 ka->sa.sa_restorer = NULL; in flush_signal_handlers()
544 sigemptyset(&ka->sa.sa_mask); in flush_signal_handlers()
551 void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler; in unhandled_signal()
563 return !tsk->ptrace; in unhandled_signal()
575 list_for_each_entry(q, &list->list, list) { in collect_signal()
576 if (q->info.si_signo == sig) { in collect_signal()
583 sigdelset(&list->signal, sig); in collect_signal()
587 list_del_init(&first->list); in collect_signal()
588 copy_siginfo(info, &first->info); in collect_signal()
591 (first->flags & SIGQUEUE_PREALLOC) && in collect_signal()
592 (info->si_code == SI_TIMER) && in collect_signal()
593 (info->si_sys_private); in collect_signal()
599 * a fast-pathed signal or we must have been in collect_signal()
603 info->si_signo = sig; in collect_signal()
604 info->si_errno = 0; in collect_signal()
605 info->si_code = SI_USER; in collect_signal()
606 info->si_pid = 0; in collect_signal()
607 info->si_uid = 0; in collect_signal()
632 lockdep_assert_held(&tsk->sighand->siglock); in dequeue_signal()
635 signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer); in dequeue_signal()
638 signr = __dequeue_signal(&tsk->signal->shared_pending, in dequeue_signal()
647 * compliant with the old way of self-restarting in dequeue_signal()
655 struct hrtimer *tmr = &tsk->signal->real_timer; in dequeue_signal()
658 tsk->signal->it_real_incr != 0) { in dequeue_signal()
659 hrtimer_forward(tmr, tmr->base->get_time(), in dequeue_signal()
660 tsk->signal->it_real_incr); in dequeue_signal()
681 * is to alert stop-signal processing code when another in dequeue_signal()
684 current->jobctl |= JOBCTL_STOP_DEQUEUED; in dequeue_signal()
691 * irqs disabled here, since the posix-timers code is in dequeue_signal()
694 spin_unlock(&tsk->sighand->siglock); in dequeue_signal()
696 spin_lock(&tsk->sighand->siglock); in dequeue_signal()
699 info->si_sys_private = 0; in dequeue_signal()
709 struct sigpending *pending = &tsk->pending; in dequeue_synchronous_signal()
715 if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK)) in dequeue_synchronous_signal()
721 list_for_each_entry(q, &pending->list, list) { in dequeue_synchronous_signal()
723 if ((q->info.si_code > SI_USER) && in dequeue_synchronous_signal()
724 (sigmask(q->info.si_signo) & SYNCHRONOUS_MASK)) { in dequeue_synchronous_signal()
734 list_for_each_entry_continue(q, &pending->list, list) { in dequeue_synchronous_signal()
735 if (q->info.si_signo == sync->info.si_signo) in dequeue_synchronous_signal()
739 sigdelset(&pending->signal, sync->info.si_signo); in dequeue_synchronous_signal()
742 list_del_init(&sync->list); in dequeue_synchronous_signal()
743 copy_siginfo(info, &sync->info); in dequeue_synchronous_signal()
745 return info->si_signo; in dequeue_synchronous_signal()
757 * goes through ->blocked
761 lockdep_assert_held(&t->sighand->siglock); in signal_wake_up_state()
767 * case. We don't check t->state here because there is a race with it in signal_wake_up_state()
787 sigandsets(&m, mask, &s->signal); in flush_sigqueue_mask()
791 sigandnsets(&s->signal, &s->signal, mask); in flush_sigqueue_mask()
792 list_for_each_entry_safe(q, n, &s->list, list) { in flush_sigqueue_mask()
793 if (sigismember(mask, q->info.si_signo)) { in flush_sigqueue_mask()
794 list_del_init(&q->list); in flush_sigqueue_mask()
819 return uid_eq(cred->euid, tcred->suid) || in kill_ok_by_cred()
820 uid_eq(cred->euid, tcred->uid) || in kill_ok_by_cred()
821 uid_eq(cred->uid, tcred->suid) || in kill_ok_by_cred()
822 uid_eq(cred->uid, tcred->uid) || in kill_ok_by_cred()
823 ns_capable(tcred->user_ns, CAP_KILL); in kill_ok_by_cred()
828 * - the caller must hold the RCU read lock
837 return -EINVAL; in check_kill_permission()
859 return -EPERM; in check_kill_permission()
867 * ptrace_trap_notify - schedule trap to notify ptracer
876 * re-trap for the new event. If trapped otherwise, STOP trap will be
881 * Must be called with @task->sighand->siglock held.
885 WARN_ON_ONCE(!(t->ptrace & PT_SEIZED)); in ptrace_trap_notify()
886 lockdep_assert_held(&t->sighand->siglock); in ptrace_trap_notify()
889 ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING); in ptrace_trap_notify()
893 * Handle magic process-wide effects of stop/continue signals. Unlike
894 * the signal actions, these happen immediately at signal-generation
904 struct signal_struct *signal = p->signal; in prepare_signal()
908 if (signal->flags & SIGNAL_GROUP_EXIT) { in prepare_signal()
909 if (signal->core_state) in prepare_signal()
920 flush_sigqueue_mask(&flush, &signal->shared_pending); in prepare_signal()
922 flush_sigqueue_mask(&flush, &t->pending); in prepare_signal()
929 flush_sigqueue_mask(&flush, &signal->shared_pending); in prepare_signal()
931 flush_sigqueue_mask(&flush, &t->pending); in prepare_signal()
933 if (likely(!(t->ptrace & PT_SEIZED))) { in prepare_signal()
934 t->jobctl &= ~JOBCTL_STOPPED; in prepare_signal()
949 if (signal->flags & SIGNAL_STOP_STOPPED) in prepare_signal()
951 else if (signal->group_stop_count) in prepare_signal()
957 * will take ->siglock, notice SIGNAL_CLD_MASK, and in prepare_signal()
961 signal->group_stop_count = 0; in prepare_signal()
962 signal->group_exit_code = 0; in prepare_signal()
979 if (sigismember(&p->blocked, sig)) in wants_signal()
982 if (p->flags & PF_EXITING) in wants_signal()
996 struct signal_struct *signal = p->signal; in complete_signal()
1016 t = signal->curr_target; in complete_signal()
1019 if (t == signal->curr_target) in complete_signal()
1027 signal->curr_target = t; in complete_signal()
1035 (signal->core_state || !(signal->flags & SIGNAL_GROUP_EXIT)) && in complete_signal()
1036 !sigismember(&t->real_blocked, sig) && in complete_signal()
1037 (sig == SIGKILL || !p->ptrace)) { in complete_signal()
1048 signal->flags = SIGNAL_GROUP_EXIT; in complete_signal()
1049 signal->group_exit_code = sig; in complete_signal()
1050 signal->group_stop_count = 0; in complete_signal()
1053 sigaddset(&t->pending.signal, SIGKILL); in complete_signal()
1061 * The signal is already in the shared-pending queue. in complete_signal()
1070 return (sig < SIGRTMIN) && sigismember(&signals->signal, sig); in legacy_queue()
1081 lockdep_assert_held(&t->sighand->siglock); in __send_signal_locked()
1087 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in __send_signal_locked()
1089 * Short-circuit ignored signals and support queuing in __send_signal_locked()
1090 * exactly one non-rt signal, so that we can get more in __send_signal_locked()
1101 if ((sig == SIGKILL) || (t->flags & PF_KTHREAD)) in __send_signal_locked()
1105 * Real-time signals must be queued if sent by sigqueue, or in __send_signal_locked()
1106 * some other real-time mechanism. It is implementation in __send_signal_locked()
1114 override_rlimit = (is_si_special(info) || info->si_code >= 0); in __send_signal_locked()
1121 list_add_tail(&q->list, &pending->list); in __send_signal_locked()
1124 clear_siginfo(&q->info); in __send_signal_locked()
1125 q->info.si_signo = sig; in __send_signal_locked()
1126 q->info.si_errno = 0; in __send_signal_locked()
1127 q->info.si_code = SI_USER; in __send_signal_locked()
1128 q->info.si_pid = task_tgid_nr_ns(current, in __send_signal_locked()
1131 q->info.si_uid = in __send_signal_locked()
1137 clear_siginfo(&q->info); in __send_signal_locked()
1138 q->info.si_signo = sig; in __send_signal_locked()
1139 q->info.si_errno = 0; in __send_signal_locked()
1140 q->info.si_code = SI_KERNEL; in __send_signal_locked()
1141 q->info.si_pid = 0; in __send_signal_locked()
1142 q->info.si_uid = 0; in __send_signal_locked()
1145 copy_siginfo(&q->info, info); in __send_signal_locked()
1149 sig >= SIGRTMIN && info->si_code != SI_USER) { in __send_signal_locked()
1156 ret = -EAGAIN; in __send_signal_locked()
1168 sigaddset(&pending->signal, sig); in __send_signal_locked()
1170 /* Let multiprocess signals appear after on-going forks */ in __send_signal_locked()
1173 hlist_for_each_entry(delayed, &t->signal->multiprocess, node) { in __send_signal_locked()
1174 sigset_t *signal = &delayed->signal; in __send_signal_locked()
1193 switch (siginfo_layout(info->si_signo, info->si_code)) { in has_si_pid_and_uid()
1233 kuid_t uid = make_kuid(current_user_ns(), info->si_uid); in send_signal_locked()
1234 info->si_uid = from_kuid_munged(t_user_ns, uid); in send_signal_locked()
1239 force = (info->si_code == SI_KERNEL); in send_signal_locked()
1243 info->si_pid = 0; in send_signal_locked()
1258 exe_file, current->comm, signr); in print_fatal_signal()
1262 current->comm, signr); in print_fatal_signal()
1266 pr_info("code at %08lx: ", regs->ip); in print_fatal_signal()
1272 if (get_user(insn, (unsigned char *)(regs->ip + i))) in print_fatal_signal()
1291 __setup("print-fatal-signals=", setup_print_fatal_signals);
1297 int ret = -ESRCH; in do_send_sig_info()
1331 int sig = info->si_signo; in force_sig_info_to_task()
1333 spin_lock_irqsave(&t->sighand->siglock, flags); in force_sig_info_to_task()
1334 action = &t->sighand->action[sig-1]; in force_sig_info_to_task()
1335 ignored = action->sa.sa_handler == SIG_IGN; in force_sig_info_to_task()
1336 blocked = sigismember(&t->blocked, sig); in force_sig_info_to_task()
1338 action->sa.sa_handler = SIG_DFL; in force_sig_info_to_task()
1340 action->sa.sa_flags |= SA_IMMUTABLE; in force_sig_info_to_task()
1342 sigdelset(&t->blocked, sig); in force_sig_info_to_task()
1348 if (action->sa.sa_handler == SIG_DFL && in force_sig_info_to_task()
1349 (!t->ptrace || (handler == HANDLER_EXIT))) in force_sig_info_to_task()
1350 t->signal->flags &= ~SIGNAL_UNKILLABLE; in force_sig_info_to_task()
1355 spin_unlock_irqrestore(&t->sighand->siglock, flags); in force_sig_info_to_task()
1373 p->signal->group_stop_count = 0; in zap_other_threads()
1380 if (t->exit_state) in zap_other_threads()
1382 sigaddset(&t->pending.signal, SIGKILL); in zap_other_threads()
1396 sighand = rcu_dereference(tsk->sighand); in __lock_task_sighand()
1403 * initializes ->siglock: this slab can't go away, it has in __lock_task_sighand()
1404 * the same object type, ->siglock can't be reinitialized. in __lock_task_sighand()
1406 * We need to ensure that tsk->sighand is still the same in __lock_task_sighand()
1409 * must see ->sighand == NULL. in __lock_task_sighand()
1411 spin_lock_irqsave(&sighand->siglock, *flags); in __lock_task_sighand()
1412 if (likely(sighand == rcu_access_pointer(tsk->sighand))) in __lock_task_sighand()
1414 spin_unlock_irqrestore(&sighand->siglock, *flags); in __lock_task_sighand()
1427 sighand = rcu_dereference(task->sighand); in lockdep_assert_task_sighand_held()
1429 lockdep_assert_held(&sighand->siglock); in lockdep_assert_task_sighand_held()
1458 * - the caller must hold at least a readlock on tasklist_lock
1463 int ret = -ESRCH; in __kill_pgrp_info()
1470 * Otherwise we return the last err or -ESRCH if this in __kill_pgrp_info()
1483 int error = -ESRCH; in kill_pid_info_type()
1492 if (likely(!p || error != -ESRCH)) in kill_pid_info_type()
1521 return uid_eq(cred->euid, pcred->suid) || in kill_as_cred_perm()
1522 uid_eq(cred->euid, pcred->uid) || in kill_as_cred_perm()
1523 uid_eq(cred->uid, pcred->suid) || in kill_as_cred_perm()
1524 uid_eq(cred->uid, pcred->uid); in kill_as_cred_perm()
1558 int ret = -EINVAL; in kill_pid_usb_asyncio()
1572 ret = -ESRCH; in kill_pid_usb_asyncio()
1576 ret = -EPERM; in kill_pid_usb_asyncio()
1588 ret = -ESRCH; in kill_pid_usb_asyncio()
1599 * POSIX specifies that kill(-1,sig) is unspecified, but what we have
1610 /* -INT_MIN is undefined. Exclude this case to avoid a UBSAN warning */ in kill_something_info()
1612 return -ESRCH; in kill_something_info()
1615 if (pid != -1) { in kill_something_info()
1617 pid ? find_vpid(-pid) : task_pgrp(current)); in kill_something_info()
1628 if (err != -EPERM) in kill_something_info()
1632 ret = count ? retval : -ESRCH; in kill_something_info()
1650 return -EINVAL; in send_sig_info()
1707 * When things go south during signal handling, we
1827 info.si_perf_flags = sigismember(&current->blocked, info.si_signo) ? in send_sig_perf()
1835 * force_sig_seccomp - signals the task to allow in-process syscall emulation
1837 * @reason: filter-supplied reason code to send to userland (via si_errno)
1858 * the errno field, instead of an actual errno value.
1937 return __sigqueue_alloc(-1, current, GFP_KERNEL, 0, SIGQUEUE_PREALLOC); in sigqueue_alloc()
1942 spinlock_t *lock = &current->sighand->siglock; in sigqueue_free()
1945 if (WARN_ON_ONCE(!(q->flags & SIGQUEUE_PREALLOC))) in sigqueue_free()
1948 * We must hold ->siglock while testing q->list in sigqueue_free()
1950 * __exit_signal()->flush_sigqueue(). in sigqueue_free()
1953 q->flags &= ~SIGQUEUE_PREALLOC; in sigqueue_free()
1958 if (!list_empty(&q->list)) in sigqueue_free()
1968 int sig = q->info.si_signo; in send_sigqueue()
1974 if (WARN_ON_ONCE(!(q->flags & SIGQUEUE_PREALLOC))) in send_sigqueue()
1976 if (WARN_ON_ONCE(q->info.si_code != SI_TIMER)) in send_sigqueue()
1979 ret = -1; in send_sigqueue()
1986 * into t->pending). in send_sigqueue()
2007 if (unlikely(!list_empty(&q->list))) { in send_sigqueue()
2012 q->info.si_overrun++; in send_sigqueue()
2016 q->info.si_overrun = 0; in send_sigqueue()
2019 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in send_sigqueue()
2020 list_add_tail(&q->list, &pending->list); in send_sigqueue()
2021 sigaddset(&pending->signal, sig); in send_sigqueue()
2025 trace_signal_generate(sig, &q->info, t, type != PIDTYPE_PID, result); in send_sigqueue()
2036 WARN_ON(task->exit_state == 0); in do_notify_pidfd()
2038 __wake_up(&pid->wait_pidfd, TASK_NORMAL, 0, in do_notify_pidfd()
2047 * self-reaping.
2057 WARN_ON_ONCE(sig == -1); in do_notify_parent()
2062 WARN_ON_ONCE(!tsk->ptrace && in do_notify_parent()
2063 (tsk->group_leader != tsk || !thread_group_empty(tsk))); in do_notify_parent()
2066 * non-PIDFD_THREAD waiters. in do_notify_parent()
2076 if (tsk->parent_exec_id != READ_ONCE(tsk->parent->self_exec_id)) in do_notify_parent()
2095 info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(tsk->parent)); in do_notify_parent()
2096 info.si_uid = from_kuid_munged(task_cred_xxx(tsk->parent, user_ns), in do_notify_parent()
2101 info.si_utime = nsec_to_clock_t(utime + tsk->signal->utime); in do_notify_parent()
2102 info.si_stime = nsec_to_clock_t(stime + tsk->signal->stime); in do_notify_parent()
2104 info.si_status = tsk->exit_code & 0x7f; in do_notify_parent()
2105 if (tsk->exit_code & 0x80) in do_notify_parent()
2107 else if (tsk->exit_code & 0x7f) in do_notify_parent()
2111 info.si_status = tsk->exit_code >> 8; in do_notify_parent()
2114 psig = tsk->parent->sighand; in do_notify_parent()
2115 spin_lock_irqsave(&psig->siglock, flags); in do_notify_parent()
2116 if (!tsk->ptrace && sig == SIGCHLD && in do_notify_parent()
2117 (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN || in do_notify_parent()
2118 (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) { in do_notify_parent()
2128 * blocked sys_wait4 might now return -ECHILD. in do_notify_parent()
2131 * is implementation-defined: we do (if you don't want in do_notify_parent()
2135 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) in do_notify_parent()
2143 __send_signal_locked(sig, &info, tsk->parent, PIDTYPE_TGID, false); in do_notify_parent()
2144 __wake_up_parent(tsk, tsk->parent); in do_notify_parent()
2145 spin_unlock_irqrestore(&psig->siglock, flags); in do_notify_parent()
2151 * do_notify_parent_cldstop - notify parent of stopped/continued state change
2158 * If %true, @tsk reports to @tsk->parent which should be the ptracer.
2173 parent = tsk->parent; in do_notify_parent_cldstop()
2175 tsk = tsk->group_leader; in do_notify_parent_cldstop()
2176 parent = tsk->real_parent; in do_notify_parent_cldstop()
2200 info.si_status = tsk->signal->group_exit_code & 0x7f; in do_notify_parent_cldstop()
2203 info.si_status = tsk->exit_code & 0x7f; in do_notify_parent_cldstop()
2209 sighand = parent->sighand; in do_notify_parent_cldstop()
2210 spin_lock_irqsave(&sighand->siglock, flags); in do_notify_parent_cldstop()
2211 if (sighand->action[SIGCHLD-1].sa.sa_handler != SIG_IGN && in do_notify_parent_cldstop()
2212 !(sighand->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) in do_notify_parent_cldstop()
2218 spin_unlock_irqrestore(&sighand->siglock, flags); in do_notify_parent_cldstop()
2222 * This must be called with current->sighand->siglock held.
2225 * We always set current->last_siginfo while stopped here.
2227 * being ptrace-stopped vs being job-control-stopped.
2235 __releases(&current->sighand->siglock) in ptrace_stop()
2236 __acquires(&current->sighand->siglock) in ptrace_stop()
2249 spin_unlock_irq(&current->sighand->siglock); in ptrace_stop()
2251 spin_lock_irq(&current->sighand->siglock); in ptrace_stop()
2260 if (!current->ptrace || __fatal_signal_pending(current)) in ptrace_stop()
2264 current->jobctl |= JOBCTL_TRACED; in ptrace_stop()
2269 * Also, transition to TRACED and updates to ->jobctl should be in ptrace_stop()
2286 current->ptrace_message = message; in ptrace_stop()
2287 current->last_siginfo = info; in ptrace_stop()
2288 current->exit_code = exit_code; in ptrace_stop()
2295 * TASK_TRACED is entered - ignore it. in ptrace_stop()
2297 if (why == CLD_STOPPED && (current->jobctl & JOBCTL_STOP_PENDING)) in ptrace_stop()
2302 if (info && info->si_code >> 8 == PTRACE_EVENT_STOP) in ptrace_stop()
2308 spin_unlock_irq(&current->sighand->siglock); in ptrace_stop()
2313 * While ptraced, there are two parents - the ptracer and in ptrace_stop()
2320 if (current->ptrace) in ptrace_stop()
2322 if (gstop_done && (!current->ptrace || ptrace_reparented(current))) in ptrace_stop()
2338 * ptracer's sleep. The preempt-disable section ensures that there in ptrace_stop()
2364 * any signal-sending on another CPU that wants to examine it. in ptrace_stop()
2366 spin_lock_irq(&current->sighand->siglock); in ptrace_stop()
2367 exit_code = current->exit_code; in ptrace_stop()
2368 current->last_siginfo = NULL; in ptrace_stop()
2369 current->ptrace_message = 0; in ptrace_stop()
2370 current->exit_code = 0; in ptrace_stop()
2373 current->jobctl &= ~(JOBCTL_LISTENING | JOBCTL_PTRACE_FROZEN); in ptrace_stop()
2406 spin_lock_irq(&current->sighand->siglock); in ptrace_notify()
2408 spin_unlock_irq(&current->sighand->siglock); in ptrace_notify()
2413 * do_signal_stop - handle group stop for SIGSTOP and other stop signals
2427 * Must be called with @current->sighand->siglock held, which is released
2435 __releases(&current->sighand->siglock) in do_signal_stop()
2437 struct signal_struct *sig = current->signal; in do_signal_stop()
2439 if (!(current->jobctl & JOBCTL_STOP_PENDING)) { in do_signal_stop()
2443 /* signr will be recorded in task->jobctl for retries */ in do_signal_stop()
2446 if (!likely(current->jobctl & JOBCTL_STOP_DEQUEUED) || in do_signal_stop()
2447 unlikely(sig->flags & SIGNAL_GROUP_EXIT) || in do_signal_stop()
2448 unlikely(sig->group_exec_task)) in do_signal_stop()
2469 if (!(sig->flags & SIGNAL_STOP_STOPPED)) in do_signal_stop()
2470 sig->group_exit_code = signr; in do_signal_stop()
2472 sig->group_stop_count = 0; in do_signal_stop()
2474 sig->group_stop_count++; in do_signal_stop()
2484 sig->group_stop_count++; in do_signal_stop()
2485 if (likely(!(t->ptrace & PT_SEIZED))) in do_signal_stop()
2493 if (likely(!current->ptrace)) { in do_signal_stop()
2504 current->jobctl |= JOBCTL_STOPPED; in do_signal_stop()
2506 spin_unlock_irq(&current->sighand->siglock); in do_signal_stop()
2538 * do_jobctl_trap - take care of ptrace jobctl traps
2549 * Must be called with @current->sighand->siglock held, which may be
2550 * released and re-acquired before returning with intervening sleep.
2554 struct signal_struct *signal = current->signal; in do_jobctl_trap()
2555 int signr = current->jobctl & JOBCTL_STOP_SIGMASK; in do_jobctl_trap()
2557 if (current->ptrace & PT_SEIZED) { in do_jobctl_trap()
2558 if (!signal->group_stop_count && in do_jobctl_trap()
2559 !(signal->flags & SIGNAL_STOP_STOPPED)) in do_jobctl_trap()
2571 * do_freezer_trap - handle the freezer jobctl trap
2577 * Must be called with @current->sighand->siglock held,
2581 __releases(&current->sighand->siglock) in do_freezer_trap()
2588 if ((current->jobctl & (JOBCTL_PENDING_MASK | JOBCTL_TRAP_FREEZE)) != in do_freezer_trap()
2590 spin_unlock_irq(&current->sighand->siglock); in do_freezer_trap()
2597 * immediately (if there is a non-fatal signal pending), and in do_freezer_trap()
2602 spin_unlock_irq(&current->sighand->siglock); in do_freezer_trap()
2626 current->jobctl |= JOBCTL_STOP_DEQUEUED; in ptrace_signal()
2639 if (signr != info->si_signo) { in ptrace_signal()
2641 info->si_signo = signr; in ptrace_signal()
2642 info->si_errno = 0; in ptrace_signal()
2643 info->si_code = SI_USER; in ptrace_signal()
2645 info->si_pid = task_pid_vnr(current->parent); in ptrace_signal()
2646 info->si_uid = from_kuid_munged(current_user_ns(), in ptrace_signal()
2647 task_uid(current->parent)); in ptrace_signal()
2652 if (sigismember(&current->blocked, signr) || in ptrace_signal()
2663 switch (siginfo_layout(ksig->sig, ksig->info.si_code)) { in hide_si_addr_tag_bits()
2670 ksig->info.si_addr = arch_untagged_si_addr( in hide_si_addr_tag_bits()
2671 ksig->info.si_addr, ksig->sig, ksig->info.si_code); in hide_si_addr_tag_bits()
2685 struct sighand_struct *sighand = current->sighand; in get_signal()
2686 struct signal_struct *signal = current->signal; in get_signal()
2700 * Do this once, we can't return to user-mode if freezing() == T. in get_signal()
2707 spin_lock_irq(&sighand->siglock); in get_signal()
2714 if (unlikely(signal->flags & SIGNAL_CLD_MASK)) { in get_signal()
2717 if (signal->flags & SIGNAL_CLD_CONTINUED) in get_signal()
2722 signal->flags &= ~SIGNAL_CLD_MASK; in get_signal()
2724 spin_unlock_irq(&sighand->siglock); in get_signal()
2728 * always per-process and doesn't make whole lot of sense in get_signal()
2737 if (ptrace_reparented(current->group_leader)) in get_signal()
2738 do_notify_parent_cldstop(current->group_leader, in get_signal()
2750 if ((signal->flags & SIGNAL_GROUP_EXIT) || in get_signal()
2751 signal->group_exec_task) { in get_signal()
2753 sigdelset(&current->pending.signal, SIGKILL); in get_signal()
2755 &sighand->action[SIGKILL-1]); in get_signal()
2759 * no need to initialize ksig->info/etc. in get_signal()
2764 if (unlikely(current->jobctl & JOBCTL_STOP_PENDING) && in get_signal()
2768 if (unlikely(current->jobctl & in get_signal()
2770 if (current->jobctl & JOBCTL_TRAP_MASK) { in get_signal()
2772 spin_unlock_irq(&sighand->siglock); in get_signal()
2773 } else if (current->jobctl & JOBCTL_TRAP_FREEZE) in get_signal()
2784 spin_unlock_irq(&sighand->siglock); in get_signal()
2796 signr = dequeue_synchronous_signal(&ksig->info); in get_signal()
2798 signr = dequeue_signal(&current->blocked, &ksig->info, &type); in get_signal()
2803 if (unlikely(current->ptrace) && (signr != SIGKILL) && in get_signal()
2804 !(sighand->action[signr -1].sa.sa_flags & SA_IMMUTABLE)) { in get_signal()
2805 signr = ptrace_signal(signr, &ksig->info, type); in get_signal()
2810 ka = &sighand->action[signr-1]; in get_signal()
2813 trace_signal_deliver(signr, &ksig->info, ka); in get_signal()
2815 if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ in get_signal()
2817 if (ka->sa.sa_handler != SIG_DFL) { in get_signal()
2819 ksig->ka = *ka; in get_signal()
2821 if (ka->sa.sa_flags & SA_ONESHOT) in get_signal()
2822 ka->sa.sa_handler = SIG_DFL; in get_signal()
2824 break; /* will return non-zero "signr" value */ in get_signal()
2835 * Container-init gets no signals it doesn't want from same in get_signal()
2838 * Note that if global/container-init sees a sig_kernel_only() in get_signal()
2843 if (unlikely(signal->flags & SIGNAL_UNKILLABLE) && in get_signal()
2859 spin_unlock_irq(&sighand->siglock); in get_signal()
2866 spin_lock_irq(&sighand->siglock); in get_signal()
2882 spin_unlock_irq(&sighand->siglock); in get_signal()
2889 current->flags |= PF_SIGNALED; in get_signal()
2903 do_coredump(&ksig->info); in get_signal()
2912 if (current->flags & PF_USER_WORKER) in get_signal()
2921 spin_unlock_irq(&sighand->siglock); in get_signal()
2923 ksig->sig = signr; in get_signal()
2925 if (signr && !(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS)) in get_signal()
2932 * signal_delivered - called after signal delivery to update blocked signals
2934 * @stepping: nonzero if debugger single-step or block-step in use
2937 * delivered. It updates the blocked signals accordingly (@ksig->ka.sa.sa_mask
2939 * is set in @ksig->ka.sa.sa_flags. Tracing is notified.
2951 sigorsets(&blocked, &current->blocked, &ksig->ka.sa.sa_mask); in signal_delivered()
2952 if (!(ksig->ka.sa.sa_flags & SA_NODEFER)) in signal_delivered()
2953 sigaddset(&blocked, ksig->sig); in signal_delivered()
2955 if (current->sas_ss_flags & SS_AUTODISARM) in signal_delivered()
2964 force_sigsegv(ksig->sig); in signal_setup_done()
2971 * group-wide signal. Other threads should be notified now to take
2979 sigandsets(&retarget, &tsk->signal->shared_pending.signal, which); in retarget_shared_pending()
2984 if (t->flags & PF_EXITING) in retarget_shared_pending()
2987 if (!has_pending_signals(&retarget, &t->blocked)) in retarget_shared_pending()
2990 sigandsets(&retarget, &retarget, &t->blocked); in retarget_shared_pending()
3006 * @tsk is about to have PF_EXITING set - lock out users which in exit_signals()
3011 if (thread_group_empty(tsk) || (tsk->signal->flags & SIGNAL_GROUP_EXIT)) { in exit_signals()
3013 tsk->flags |= PF_EXITING; in exit_signals()
3018 spin_lock_irq(&tsk->sighand->siglock); in exit_signals()
3020 * From now this task is not visible for group-wide signals, in exit_signals()
3024 tsk->flags |= PF_EXITING; in exit_signals()
3031 unblocked = tsk->blocked; in exit_signals()
3035 if (unlikely(tsk->jobctl & JOBCTL_STOP_PENDING) && in exit_signals()
3039 spin_unlock_irq(&tsk->sighand->siglock); in exit_signals()
3057 * sys_restart_syscall - restart a system call
3061 struct restart_block *restart = &current->restart_block; in SYSCALL_DEFINE0()
3062 return restart->fn(restart); in SYSCALL_DEFINE0()
3067 return -EINTR; in do_no_restart_syscall()
3075 sigandnsets(&newblocked, newset, &current->blocked); in __set_task_blocked()
3078 tsk->blocked = *newset; in __set_task_blocked()
3083 * set_current_blocked - change current->blocked mask
3086 * It is wrong to change ->blocked directly, this helper should be used
3101 * to do. The current->blocked shouldn't be modified by other task. in __set_current_blocked()
3103 if (sigequalsets(&tsk->blocked, newset)) in __set_current_blocked()
3106 spin_lock_irq(&tsk->sighand->siglock); in __set_current_blocked()
3108 spin_unlock_irq(&tsk->sighand->siglock); in __set_current_blocked()
3115 * NOTE! Unlike the user-mode sys_sigprocmask(), the kernel
3124 /* Lockless, only current can change ->blocked, never from irq */ in sigprocmask()
3126 *oldset = tsk->blocked; in sigprocmask()
3130 sigorsets(&newset, &tsk->blocked, set); in sigprocmask()
3133 sigandnsets(&newset, &tsk->blocked, set); in sigprocmask()
3139 return -EINVAL; in sigprocmask()
3148 * The api helps set app-provided sigmasks.
3163 return -EINVAL; in set_user_sigmask()
3165 return -EFAULT; in set_user_sigmask()
3168 current->saved_sigmask = current->blocked; in set_user_sigmask()
3183 return -EINVAL; in set_compat_user_sigmask()
3185 return -EFAULT; in set_compat_user_sigmask()
3188 current->saved_sigmask = current->blocked; in set_compat_user_sigmask()
3196 * sys_rt_sigprocmask - change the list of currently blocked signals
3199 * @oset: previous value of signal mask if non-null
3210 return -EINVAL; in SYSCALL_DEFINE4()
3212 old_set = current->blocked; in SYSCALL_DEFINE4()
3216 return -EFAULT; in SYSCALL_DEFINE4()
3226 return -EFAULT; in SYSCALL_DEFINE4()
3236 sigset_t old_set = current->blocked; in COMPAT_SYSCALL_DEFINE4()
3240 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
3246 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3259 spin_lock_irq(&current->sighand->siglock); in do_sigpending()
3260 sigorsets(set, &current->pending.signal, in do_sigpending()
3261 &current->signal->shared_pending.signal); in do_sigpending()
3262 spin_unlock_irq(&current->sighand->siglock); in do_sigpending()
3265 sigandsets(set, &current->blocked, set); in do_sigpending()
3269 * sys_rt_sigpending - examine a pending signal that has been raised
3279 return -EINVAL; in SYSCALL_DEFINE2()
3284 return -EFAULT; in SYSCALL_DEFINE2()
3296 return -EINVAL; in COMPAT_SYSCALL_DEFINE2()
3388 return -EFAULT; in copy_siginfo_to_user()
3390 return -EFAULT; in copy_siginfo_to_user()
3397 if (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) { in post_copy_siginfo_from_user()
3408 return -EFAULT; in post_copy_siginfo_from_user()
3411 return -E2BIG; in post_copy_siginfo_from_user()
3421 return -EFAULT; in __copy_siginfo_from_user()
3422 to->si_signo = signo; in __copy_siginfo_from_user()
3429 return -EFAULT; in copy_siginfo_from_user()
3435 * copy_siginfo_to_external32 - copy a kernel siginfo into a compat user siginfo
3449 to->si_signo = from->si_signo; in copy_siginfo_to_external32()
3450 to->si_errno = from->si_errno; in copy_siginfo_to_external32()
3451 to->si_code = from->si_code; in copy_siginfo_to_external32()
3452 switch(siginfo_layout(from->si_signo, from->si_code)) { in copy_siginfo_to_external32()
3454 to->si_pid = from->si_pid; in copy_siginfo_to_external32()
3455 to->si_uid = from->si_uid; in copy_siginfo_to_external32()
3458 to->si_tid = from->si_tid; in copy_siginfo_to_external32()
3459 to->si_overrun = from->si_overrun; in copy_siginfo_to_external32()
3460 to->si_int = from->si_int; in copy_siginfo_to_external32()
3463 to->si_band = from->si_band; in copy_siginfo_to_external32()
3464 to->si_fd = from->si_fd; in copy_siginfo_to_external32()
3467 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3470 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3471 to->si_trapno = from->si_trapno; in copy_siginfo_to_external32()
3474 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3475 to->si_addr_lsb = from->si_addr_lsb; in copy_siginfo_to_external32()
3478 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3479 to->si_lower = ptr_to_compat(from->si_lower); in copy_siginfo_to_external32()
3480 to->si_upper = ptr_to_compat(from->si_upper); in copy_siginfo_to_external32()
3483 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3484 to->si_pkey = from->si_pkey; in copy_siginfo_to_external32()
3487 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3488 to->si_perf_data = from->si_perf_data; in copy_siginfo_to_external32()
3489 to->si_perf_type = from->si_perf_type; in copy_siginfo_to_external32()
3490 to->si_perf_flags = from->si_perf_flags; in copy_siginfo_to_external32()
3493 to->si_pid = from->si_pid; in copy_siginfo_to_external32()
3494 to->si_uid = from->si_uid; in copy_siginfo_to_external32()
3495 to->si_status = from->si_status; in copy_siginfo_to_external32()
3496 to->si_utime = from->si_utime; in copy_siginfo_to_external32()
3497 to->si_stime = from->si_stime; in copy_siginfo_to_external32()
3500 to->si_pid = from->si_pid; in copy_siginfo_to_external32()
3501 to->si_uid = from->si_uid; in copy_siginfo_to_external32()
3502 to->si_int = from->si_int; in copy_siginfo_to_external32()
3505 to->si_call_addr = ptr_to_compat(from->si_call_addr); in copy_siginfo_to_external32()
3506 to->si_syscall = from->si_syscall; in copy_siginfo_to_external32()
3507 to->si_arch = from->si_arch; in copy_siginfo_to_external32()
3519 return -EFAULT; in __copy_siginfo_to_user32()
3527 to->si_signo = from->si_signo; in post_copy_siginfo_from_user32()
3528 to->si_errno = from->si_errno; in post_copy_siginfo_from_user32()
3529 to->si_code = from->si_code; in post_copy_siginfo_from_user32()
3530 switch(siginfo_layout(from->si_signo, from->si_code)) { in post_copy_siginfo_from_user32()
3532 to->si_pid = from->si_pid; in post_copy_siginfo_from_user32()
3533 to->si_uid = from->si_uid; in post_copy_siginfo_from_user32()
3536 to->si_tid = from->si_tid; in post_copy_siginfo_from_user32()
3537 to->si_overrun = from->si_overrun; in post_copy_siginfo_from_user32()
3538 to->si_int = from->si_int; in post_copy_siginfo_from_user32()
3541 to->si_band = from->si_band; in post_copy_siginfo_from_user32()
3542 to->si_fd = from->si_fd; in post_copy_siginfo_from_user32()
3545 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3548 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3549 to->si_trapno = from->si_trapno; in post_copy_siginfo_from_user32()
3552 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3553 to->si_addr_lsb = from->si_addr_lsb; in post_copy_siginfo_from_user32()
3556 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3557 to->si_lower = compat_ptr(from->si_lower); in post_copy_siginfo_from_user32()
3558 to->si_upper = compat_ptr(from->si_upper); in post_copy_siginfo_from_user32()
3561 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3562 to->si_pkey = from->si_pkey; in post_copy_siginfo_from_user32()
3565 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3566 to->si_perf_data = from->si_perf_data; in post_copy_siginfo_from_user32()
3567 to->si_perf_type = from->si_perf_type; in post_copy_siginfo_from_user32()
3568 to->si_perf_flags = from->si_perf_flags; in post_copy_siginfo_from_user32()
3571 to->si_pid = from->si_pid; in post_copy_siginfo_from_user32()
3572 to->si_uid = from->si_uid; in post_copy_siginfo_from_user32()
3573 to->si_status = from->si_status; in post_copy_siginfo_from_user32()
3576 to->si_utime = from->_sifields._sigchld_x32._utime; in post_copy_siginfo_from_user32()
3577 to->si_stime = from->_sifields._sigchld_x32._stime; in post_copy_siginfo_from_user32()
3581 to->si_utime = from->si_utime; in post_copy_siginfo_from_user32()
3582 to->si_stime = from->si_stime; in post_copy_siginfo_from_user32()
3586 to->si_pid = from->si_pid; in post_copy_siginfo_from_user32()
3587 to->si_uid = from->si_uid; in post_copy_siginfo_from_user32()
3588 to->si_int = from->si_int; in post_copy_siginfo_from_user32()
3591 to->si_call_addr = compat_ptr(from->si_call_addr); in post_copy_siginfo_from_user32()
3592 to->si_syscall = from->si_syscall; in post_copy_siginfo_from_user32()
3593 to->si_arch = from->si_arch; in post_copy_siginfo_from_user32()
3605 return -EFAULT; in __copy_siginfo_from_user32()
3617 return -EFAULT; in copy_siginfo_from_user32()
3624 * do_sigtimedwait - wait for queued signals specified in @which
3626 * @info: if non-null, the signal's siginfo is returned here
3640 return -EINVAL; in do_sigtimedwait()
3651 spin_lock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3660 tsk->real_blocked = tsk->blocked; in do_sigtimedwait()
3661 sigandsets(&tsk->blocked, &tsk->blocked, &mask); in do_sigtimedwait()
3663 spin_unlock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3666 ret = schedule_hrtimeout_range(to, tsk->timer_slack_ns, in do_sigtimedwait()
3668 spin_lock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3669 __set_task_blocked(tsk, &tsk->real_blocked); in do_sigtimedwait()
3670 sigemptyset(&tsk->real_blocked); in do_sigtimedwait()
3673 spin_unlock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3677 return ret ? -EINTR : -EAGAIN; in do_sigtimedwait()
3681 * sys_rt_sigtimedwait - synchronously wait for queued signals specified
3684 * @uinfo: if non-null, the signal's siginfo is returned here
3700 return -EINVAL; in SYSCALL_DEFINE4()
3703 return -EFAULT; in SYSCALL_DEFINE4()
3707 return -EFAULT; in SYSCALL_DEFINE4()
3714 ret = -EFAULT; in SYSCALL_DEFINE4()
3732 return -EINVAL; in SYSCALL_DEFINE4()
3735 return -EFAULT; in SYSCALL_DEFINE4()
3739 return -EFAULT; in SYSCALL_DEFINE4()
3746 ret = -EFAULT; in SYSCALL_DEFINE4()
3764 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
3767 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3771 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3778 ret = -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3795 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
3798 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3802 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3809 ret = -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3821 info->si_signo = sig; in prepare_kill_siginfo()
3822 info->si_errno = 0; in prepare_kill_siginfo()
3823 info->si_code = (type == PIDTYPE_PID) ? SI_TKILL : SI_USER; in prepare_kill_siginfo()
3824 info->si_pid = task_tgid_vnr(current); in prepare_kill_siginfo()
3825 info->si_uid = from_kuid_munged(current_user_ns(), current_uid()); in prepare_kill_siginfo()
3829 * sys_kill - send a signal to a process
3857 p = p->parent; in access_pidfd_pidns()
3869 * conversions here. Note, this is a stop-gap measure and should not be in copy_siginfo_from_user_any()
3895 * sys_pidfd_send_signal - Signal a process through a pidfd
3919 return -EINVAL; in SYSCALL_DEFINE4()
3923 return -EINVAL; in SYSCALL_DEFINE4()
3927 return -EBADF; in SYSCALL_DEFINE4()
3936 ret = -EINVAL; in SYSCALL_DEFINE4()
3943 if (fd_file(f)->f_flags & PIDFD_THREAD) in SYSCALL_DEFINE4()
3964 ret = -EINVAL; in SYSCALL_DEFINE4()
3969 ret = -EPERM; in SYSCALL_DEFINE4()
3990 int error = -ESRCH; in do_send_specific()
4007 if (unlikely(error == -ESRCH)) in do_send_specific()
4026 * sys_tgkill - send signal to one specific thread
4031 * This syscall also checks the @tgid and returns -ESRCH even if the PID
4039 return -EINVAL; in SYSCALL_DEFINE3()
4045 * sys_tkill - send signal to one specific task
4055 return -EINVAL; in SYSCALL_DEFINE2()
4065 if ((info->si_code >= 0 || info->si_code == SI_TKILL) && in do_rt_sigqueueinfo()
4067 return -EPERM; in do_rt_sigqueueinfo()
4074 * sys_rt_sigqueueinfo - send signal information to a signal
4107 return -EINVAL; in do_rt_tgsigqueueinfo()
4112 if ((info->si_code >= 0 || info->si_code == SI_TKILL) && in do_rt_tgsigqueueinfo()
4114 return -EPERM; in do_rt_tgsigqueueinfo()
4149 spin_lock_irq(&current->sighand->siglock); in kernel_sigaction()
4150 current->sighand->action[sig - 1].sa.sa_handler = action; in kernel_sigaction()
4157 flush_sigqueue_mask(&mask, &current->signal->shared_pending); in kernel_sigaction()
4158 flush_sigqueue_mask(&mask, &current->pending); in kernel_sigaction()
4161 spin_unlock_irq(&current->sighand->siglock); in kernel_sigaction()
4177 return -EINVAL; in do_sigaction()
4179 k = &p->sighand->action[sig-1]; in do_sigaction()
4181 spin_lock_irq(&p->sighand->siglock); in do_sigaction()
4182 if (k->sa.sa_flags & SA_IMMUTABLE) { in do_sigaction()
4183 spin_unlock_irq(&p->sighand->siglock); in do_sigaction()
4184 return -EINVAL; in do_sigaction()
4197 * support for flag bits and to allow the kernel to use non-uapi bits in do_sigaction()
4201 act->sa.sa_flags &= UAPI_SA_FLAGS; in do_sigaction()
4203 oact->sa.sa_flags &= UAPI_SA_FLAGS; in do_sigaction()
4208 sigdelsetmask(&act->sa.sa_mask, in do_sigaction()
4225 flush_sigqueue_mask(&mask, &p->signal->shared_pending); in do_sigaction()
4227 flush_sigqueue_mask(&mask, &t->pending); in do_sigaction()
4231 spin_unlock_irq(&p->sighand->siglock); in do_sigaction()
4237 __acquires(&current->sighand->siglock) in sigaltstack_lock()
4239 spin_lock_irq(&current->sighand->siglock); in sigaltstack_lock()
4243 __releases(&current->sighand->siglock) in sigaltstack_unlock()
4245 spin_unlock_irq(&current->sighand->siglock); in sigaltstack_unlock()
4261 oss->ss_sp = (void __user *) t->sas_ss_sp; in do_sigaltstack()
4262 oss->ss_size = t->sas_ss_size; in do_sigaltstack()
4263 oss->ss_flags = sas_ss_flags(sp) | in do_sigaltstack()
4264 (current->sas_ss_flags & SS_FLAG_BITS); in do_sigaltstack()
4268 void __user *ss_sp = ss->ss_sp; in do_sigaltstack()
4269 size_t ss_size = ss->ss_size; in do_sigaltstack()
4270 unsigned ss_flags = ss->ss_flags; in do_sigaltstack()
4274 return -EPERM; in do_sigaltstack()
4279 return -EINVAL; in do_sigaltstack()
4285 if (t->sas_ss_sp == (unsigned long)ss_sp && in do_sigaltstack()
4286 t->sas_ss_size == ss_size && in do_sigaltstack()
4287 t->sas_ss_flags == ss_flags) in do_sigaltstack()
4296 ret = -ENOMEM; in do_sigaltstack()
4298 ret = -ENOMEM; in do_sigaltstack()
4301 t->sas_ss_sp = (unsigned long) ss_sp; in do_sigaltstack()
4302 t->sas_ss_size = ss_size; in do_sigaltstack()
4303 t->sas_ss_flags = ss_flags; in do_sigaltstack()
4315 return -EFAULT; in SYSCALL_DEFINE2()
4320 err = -EFAULT; in SYSCALL_DEFINE2()
4328 return -EFAULT; in restore_altstack()
4338 int err = __put_user((void __user *)t->sas_ss_sp, &uss->ss_sp) | in __save_altstack()
4339 __put_user(t->sas_ss_flags, &uss->ss_flags) | in __save_altstack()
4340 __put_user(t->sas_ss_size, &uss->ss_size); in __save_altstack()
4354 return -EFAULT; in do_compat_sigaltstack()
4369 ret = -EFAULT; in do_compat_sigaltstack()
4384 /* squash all but -EFAULT for now */ in compat_restore_altstack()
4385 return err == -EFAULT ? err : 0; in compat_restore_altstack()
4392 err = __put_user(ptr_to_compat((void __user *)t->sas_ss_sp), in __compat_save_altstack()
4393 &uss->ss_sp) | in __compat_save_altstack()
4394 __put_user(t->sas_ss_flags, &uss->ss_flags) | in __compat_save_altstack()
4395 __put_user(t->sas_ss_size, &uss->ss_size); in __compat_save_altstack()
4403 * sys_sigpending - examine pending signals
4411 return -EINVAL; in SYSCALL_DEFINE1()
4416 return -EFAULT; in SYSCALL_DEFINE1()
4436 * sys_sigprocmask - examine and change blocked signals
4438 * @nset: signals to add or remove (if non-null)
4439 * @oset: previous value of signal mask if non-null
4451 old_set = current->blocked.sig[0]; in SYSCALL_DEFINE3()
4455 return -EFAULT; in SYSCALL_DEFINE3()
4457 new_blocked = current->blocked; in SYSCALL_DEFINE3()
4470 return -EINVAL; in SYSCALL_DEFINE3()
4478 return -EFAULT; in SYSCALL_DEFINE3()
4487 * sys_rt_sigaction - alter an action taken by a process
4503 return -EINVAL; in SYSCALL_DEFINE4()
4506 return -EFAULT; in SYSCALL_DEFINE4()
4513 return -EFAULT; in SYSCALL_DEFINE4()
4531 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
4535 ret = get_user(handler, &act->sa_handler); in COMPAT_SYSCALL_DEFINE4()
4538 ret |= get_user(restorer, &act->sa_restorer); in COMPAT_SYSCALL_DEFINE4()
4541 ret |= get_compat_sigset(&new_ka.sa.sa_mask, &act->sa_mask); in COMPAT_SYSCALL_DEFINE4()
4542 ret |= get_user(new_ka.sa.sa_flags, &act->sa_flags); in COMPAT_SYSCALL_DEFINE4()
4544 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
4550 &oact->sa_handler); in COMPAT_SYSCALL_DEFINE4()
4551 ret |= put_compat_sigset(&oact->sa_mask, &old_ka.sa.sa_mask, in COMPAT_SYSCALL_DEFINE4()
4552 sizeof(oact->sa_mask)); in COMPAT_SYSCALL_DEFINE4()
4553 ret |= put_user(old_ka.sa.sa_flags, &oact->sa_flags); in COMPAT_SYSCALL_DEFINE4()
4556 &oact->sa_restorer); in COMPAT_SYSCALL_DEFINE4()
4575 __get_user(new_ka.sa.sa_handler, &act->sa_handler) || in SYSCALL_DEFINE3()
4576 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) || in SYSCALL_DEFINE3()
4577 __get_user(new_ka.sa.sa_flags, &act->sa_flags) || in SYSCALL_DEFINE3()
4578 __get_user(mask, &act->sa_mask)) in SYSCALL_DEFINE3()
4579 return -EFAULT; in SYSCALL_DEFINE3()
4590 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || in SYSCALL_DEFINE3()
4591 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) || in SYSCALL_DEFINE3()
4592 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || in SYSCALL_DEFINE3()
4593 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) in SYSCALL_DEFINE3()
4594 return -EFAULT; in SYSCALL_DEFINE3()
4612 __get_user(handler, &act->sa_handler) || in COMPAT_SYSCALL_DEFINE3()
4613 __get_user(restorer, &act->sa_restorer) || in COMPAT_SYSCALL_DEFINE3()
4614 __get_user(new_ka.sa.sa_flags, &act->sa_flags) || in COMPAT_SYSCALL_DEFINE3()
4615 __get_user(mask, &act->sa_mask)) in COMPAT_SYSCALL_DEFINE3()
4616 return -EFAULT; in COMPAT_SYSCALL_DEFINE3()
4631 &oact->sa_handler) || in COMPAT_SYSCALL_DEFINE3()
4633 &oact->sa_restorer) || in COMPAT_SYSCALL_DEFINE3()
4634 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || in COMPAT_SYSCALL_DEFINE3()
4635 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) in COMPAT_SYSCALL_DEFINE3()
4636 return -EFAULT; in COMPAT_SYSCALL_DEFINE3()
4650 return current->blocked.sig[0]; in SYSCALL_DEFINE0()
4655 int old = current->blocked.sig[0]; in SYSCALL_DEFINE1()
4692 return -ERESTARTNOHAND; in SYSCALL_DEFINE0()
4699 current->saved_sigmask = current->blocked; in sigsuspend()
4707 return -ERESTARTNOHAND; in sigsuspend()
4711 * sys_rt_sigsuspend - replace the signal mask for a value with the
4722 return -EINVAL; in SYSCALL_DEFINE2()
4725 return -EFAULT; in SYSCALL_DEFINE2()
4736 return -EINVAL; in COMPAT_SYSCALL_DEFINE2()
4739 return -EFAULT; in COMPAT_SYSCALL_DEFINE2()
4771 #define CHECK_OFFSET(field) \ in siginfo_buildtime_checks() argument
4772 BUILD_BUG_ON(offsetof(siginfo_t, field) != offsetof(kernel_siginfo_t, field)) in siginfo_buildtime_checks()
4843 .procname = "exception-trace",
4870 * kdb_send_sig - Allows kdb to send signals without exposing
4879 if (!spin_trylock(&t->sighand->siglock)) { in kdb_send_sig()
4888 spin_unlock(&t->sighand->siglock); in kdb_send_sig()
4898 spin_unlock(&t->sighand->siglock); in kdb_send_sig()
4901 sig, t->pid); in kdb_send_sig()
4903 kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid); in kdb_send_sig()