Lines Matching +full:tmr +full:- +full:add
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>
62 #include "time/posix-timers.h"
74 return t->sighand->action[sig - 1].sa.sa_handler; in sig_handler()
94 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && in sig_task_ignored()
99 if (unlikely((t->flags & PF_KTHREAD) && in sig_task_ignored()
113 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) in sig_ignored()
121 if (t->ptrace && sig != SIGKILL) in sig_ignored()
128 * Re-calculate pending state from the set of locally pending
138 for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;) in has_pending_signals()
139 ready |= signal->sig[i] &~ blocked->sig[i]; in has_pending_signals()
142 case 4: ready = signal->sig[3] &~ blocked->sig[3]; in has_pending_signals()
143 ready |= signal->sig[2] &~ blocked->sig[2]; in has_pending_signals()
144 ready |= signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
145 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
148 case 2: ready = signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
149 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
152 case 1: ready = signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
157 #define PENDING(p,b) has_pending_signals(&(p)->signal, (b))
161 if ((t->jobctl & (JOBCTL_PENDING_MASK | JOBCTL_TRAP_FREEZE)) || in recalc_sigpending_tsk()
162 PENDING(&t->pending, &t->blocked) || in recalc_sigpending_tsk()
163 PENDING(&t->signal->shared_pending, &t->blocked) || in recalc_sigpending_tsk()
171 * when it's possible the current syscall is returning -ERESTART*. in recalc_sigpending_tsk()
190 spin_lock_irq(¤t->sighand->siglock); in calculate_sigpending()
193 spin_unlock_irq(¤t->sighand->siglock); in calculate_sigpending()
207 s = pending->signal.sig; in next_signal()
208 m = mask->sig; in next_signal()
259 current->comm, current->pid, sig); in print_dropped_signal()
263 * task_set_jobctl_pending - set jobctl pending bits
267 * Clear @mask from @task->jobctl. @mask must be subset of
274 * Must be called with @task->sighand->siglock held.
285 if (unlikely(fatal_signal_pending(task) || (task->flags & PF_EXITING))) in task_set_jobctl_pending()
289 task->jobctl &= ~JOBCTL_STOP_SIGMASK; in task_set_jobctl_pending()
291 task->jobctl |= mask; in task_set_jobctl_pending()
296 * task_clear_jobctl_trapping - clear jobctl trapping bit
301 * locking. @task->siglock guarantees that @task->parent points to the
305 * Must be called with @task->sighand->siglock held.
309 if (unlikely(task->jobctl & JOBCTL_TRAPPING)) { in task_clear_jobctl_trapping()
310 task->jobctl &= ~JOBCTL_TRAPPING; in task_clear_jobctl_trapping()
312 wake_up_bit(&task->jobctl, JOBCTL_TRAPPING_BIT); in task_clear_jobctl_trapping()
317 * task_clear_jobctl_pending - clear jobctl pending bits
321 * Clear @mask from @task->jobctl. @mask must be subset of
329 * Must be called with @task->sighand->siglock held.
338 task->jobctl &= ~mask; in task_clear_jobctl_pending()
340 if (!(task->jobctl & JOBCTL_PENDING_MASK)) in task_clear_jobctl_pending()
345 * task_participate_group_stop - participate in a group stop
354 * Must be called with @task->sighand->siglock held.
362 struct signal_struct *sig = task->signal; in task_participate_group_stop()
363 bool consume = task->jobctl & JOBCTL_STOP_CONSUME; in task_participate_group_stop()
365 WARN_ON_ONCE(!(task->jobctl & JOBCTL_STOP_PENDING)); in task_participate_group_stop()
372 if (!WARN_ON_ONCE(sig->group_stop_count == 0)) in task_participate_group_stop()
373 sig->group_stop_count--; in task_participate_group_stop()
379 if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) { in task_participate_group_stop()
388 unsigned long mask = current->jobctl & JOBCTL_STOP_SIGMASK; in task_join_group_stop()
389 struct signal_struct *sig = current->signal; in task_join_group_stop()
391 if (sig->group_stop_count) { in task_join_group_stop()
392 sig->group_stop_count++; in task_join_group_stop()
394 } else if (!(sig->flags & SIGNAL_STOP_STOPPED)) in task_join_group_stop()
397 /* Have the new thread join an on-going signal group stop */ in task_join_group_stop()
435 INIT_LIST_HEAD(&q->list); in __sigqueue_init()
436 q->flags = sigqueue_flags; in __sigqueue_init()
437 q->ucounts = ucounts; in __sigqueue_init()
442 * - this may be called without locks if and only if t == current, otherwise an
466 if (q->flags & SIGQUEUE_PREALLOC) { in __sigqueue_free()
470 if (q->ucounts) { in __sigqueue_free()
471 dec_rlimit_put_ucounts(q->ucounts, UCOUNT_RLIMIT_SIGPENDING); in __sigqueue_free()
472 q->ucounts = NULL; in __sigqueue_free()
481 sigemptyset(&queue->signal); in flush_sigqueue()
482 while (!list_empty(&queue->list)) { in flush_sigqueue()
483 q = list_entry(queue->list.next, struct sigqueue , list); in flush_sigqueue()
484 list_del_init(&q->list); in flush_sigqueue()
496 spin_lock_irqsave(&t->sighand->siglock, flags); in flush_signals()
498 flush_sigqueue(&t->pending); in flush_signals()
499 flush_sigqueue(&t->signal->shared_pending); in flush_signals()
500 spin_unlock_irqrestore(&t->sighand->siglock, flags); in flush_signals()
509 t->sighand->action[i].sa.sa_handler = SIG_IGN; in ignore_signals()
522 struct k_sigaction *ka = &t->sighand->action[0]; in flush_signal_handlers()
523 for (i = _NSIG ; i != 0 ; i--) { in flush_signal_handlers()
524 if (force_default || ka->sa.sa_handler != SIG_IGN) in flush_signal_handlers()
525 ka->sa.sa_handler = SIG_DFL; in flush_signal_handlers()
526 ka->sa.sa_flags = 0; in flush_signal_handlers()
528 ka->sa.sa_restorer = NULL; in flush_signal_handlers()
530 sigemptyset(&ka->sa.sa_mask); in flush_signal_handlers()
537 void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler; in unhandled_signal()
549 return !tsk->ptrace; in unhandled_signal()
561 list_for_each_entry(q, &list->list, list) { in collect_signal()
562 if (q->info.si_signo == sig) { in collect_signal()
569 sigdelset(&list->signal, sig); in collect_signal()
573 list_del_init(&first->list); in collect_signal()
574 copy_siginfo(info, &first->info); in collect_signal()
577 * posix-timer signals are preallocated and freed when the last in collect_signal()
583 if (unlikely((first->flags & SIGQUEUE_PREALLOC) && (info->si_code == SI_TIMER))) in collect_signal()
590 * a fast-pathed signal or we must have been in collect_signal()
594 info->si_signo = sig; in collect_signal()
595 info->si_errno = 0; in collect_signal()
596 info->si_code = SI_USER; in collect_signal()
597 info->si_pid = 0; in collect_signal()
598 info->si_uid = 0; in collect_signal()
623 lockdep_assert_held(&tsk->sighand->siglock); in dequeue_signal()
628 signr = __dequeue_signal(&tsk->pending, mask, info, &timer_sigq); in dequeue_signal()
631 signr = __dequeue_signal(&tsk->signal->shared_pending, in dequeue_signal()
652 * is to alert stop-signal processing code when another in dequeue_signal()
655 current->jobctl |= JOBCTL_STOP_DEQUEUED; in dequeue_signal()
670 struct sigpending *pending = &tsk->pending; in dequeue_synchronous_signal()
676 if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK)) in dequeue_synchronous_signal()
682 list_for_each_entry(q, &pending->list, list) { in dequeue_synchronous_signal()
684 if ((q->info.si_code > SI_USER) && in dequeue_synchronous_signal()
685 (sigmask(q->info.si_signo) & SYNCHRONOUS_MASK)) { in dequeue_synchronous_signal()
695 list_for_each_entry_continue(q, &pending->list, list) { in dequeue_synchronous_signal()
696 if (q->info.si_signo == sync->info.si_signo) in dequeue_synchronous_signal()
700 sigdelset(&pending->signal, sync->info.si_signo); in dequeue_synchronous_signal()
703 list_del_init(&sync->list); in dequeue_synchronous_signal()
704 copy_siginfo(info, &sync->info); in dequeue_synchronous_signal()
706 return info->si_signo; in dequeue_synchronous_signal()
718 * goes through ->blocked
722 lockdep_assert_held(&t->sighand->siglock); in signal_wake_up_state()
728 * case. We don't check t->state here because there is a race with it in signal_wake_up_state()
741 if (likely(!(q->flags & SIGQUEUE_PREALLOC) || q->info.si_code != SI_TIMER)) in sigqueue_free_ignored()
753 lockdep_assert_held(&p->sighand->siglock); in flush_sigqueue_mask()
755 sigandsets(&m, mask, &s->signal); in flush_sigqueue_mask()
759 sigandnsets(&s->signal, &s->signal, mask); in flush_sigqueue_mask()
760 list_for_each_entry_safe(q, n, &s->list, list) { in flush_sigqueue_mask()
761 if (sigismember(mask, q->info.si_signo)) { in flush_sigqueue_mask()
762 list_del_init(&q->list); in flush_sigqueue_mask()
787 return uid_eq(cred->euid, tcred->suid) || in kill_ok_by_cred()
788 uid_eq(cred->euid, tcred->uid) || in kill_ok_by_cred()
789 uid_eq(cred->uid, tcred->suid) || in kill_ok_by_cred()
790 uid_eq(cred->uid, tcred->uid) || in kill_ok_by_cred()
791 ns_capable(tcred->user_ns, CAP_KILL); in kill_ok_by_cred()
796 * - the caller must hold the RCU read lock
805 return -EINVAL; in check_kill_permission()
827 return -EPERM; in check_kill_permission()
835 * ptrace_trap_notify - schedule trap to notify ptracer
844 * re-trap for the new event. If trapped otherwise, STOP trap will be
849 * Must be called with @task->sighand->siglock held.
853 WARN_ON_ONCE(!(t->ptrace & PT_SEIZED)); in ptrace_trap_notify()
854 lockdep_assert_held(&t->sighand->siglock); in ptrace_trap_notify()
857 ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING); in ptrace_trap_notify()
861 * Handle magic process-wide effects of stop/continue signals. Unlike
862 * the signal actions, these happen immediately at signal-generation
872 struct signal_struct *signal = p->signal; in prepare_signal()
876 if (signal->flags & SIGNAL_GROUP_EXIT) { in prepare_signal()
877 if (signal->core_state) in prepare_signal()
888 flush_sigqueue_mask(p, &flush, &signal->shared_pending); in prepare_signal()
890 flush_sigqueue_mask(p, &flush, &t->pending); in prepare_signal()
897 flush_sigqueue_mask(p, &flush, &signal->shared_pending); in prepare_signal()
899 flush_sigqueue_mask(p, &flush, &t->pending); in prepare_signal()
901 if (likely(!(t->ptrace & PT_SEIZED))) { in prepare_signal()
902 t->jobctl &= ~JOBCTL_STOPPED; in prepare_signal()
917 if (signal->flags & SIGNAL_STOP_STOPPED) in prepare_signal()
919 else if (signal->group_stop_count) in prepare_signal()
925 * will take ->siglock, notice SIGNAL_CLD_MASK, and in prepare_signal()
929 signal->group_stop_count = 0; in prepare_signal()
930 signal->group_exit_code = 0; in prepare_signal()
947 if (sigismember(&p->blocked, sig)) in wants_signal()
950 if (p->flags & PF_EXITING) in wants_signal()
964 struct signal_struct *signal = p->signal; in complete_signal()
984 t = signal->curr_target; in complete_signal()
987 if (t == signal->curr_target) in complete_signal()
995 signal->curr_target = t; in complete_signal()
1003 (signal->core_state || !(signal->flags & SIGNAL_GROUP_EXIT)) && in complete_signal()
1004 !sigismember(&t->real_blocked, sig) && in complete_signal()
1005 (sig == SIGKILL || !p->ptrace)) { in complete_signal()
1016 signal->flags = SIGNAL_GROUP_EXIT; in complete_signal()
1017 signal->group_exit_code = sig; in complete_signal()
1018 signal->group_stop_count = 0; in complete_signal()
1021 sigaddset(&t->pending.signal, SIGKILL); in complete_signal()
1029 * The signal is already in the shared-pending queue. in complete_signal()
1038 return (sig < SIGRTMIN) && sigismember(&signals->signal, sig); in legacy_queue()
1049 lockdep_assert_held(&t->sighand->siglock); in __send_signal_locked()
1055 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in __send_signal_locked()
1057 * Short-circuit ignored signals and support queuing in __send_signal_locked()
1058 * exactly one non-rt signal, so that we can get more in __send_signal_locked()
1069 if ((sig == SIGKILL) || (t->flags & PF_KTHREAD)) in __send_signal_locked()
1073 * Real-time signals must be queued if sent by sigqueue, or in __send_signal_locked()
1074 * some other real-time mechanism. It is implementation in __send_signal_locked()
1082 override_rlimit = (is_si_special(info) || info->si_code >= 0); in __send_signal_locked()
1089 list_add_tail(&q->list, &pending->list); in __send_signal_locked()
1092 clear_siginfo(&q->info); in __send_signal_locked()
1093 q->info.si_signo = sig; in __send_signal_locked()
1094 q->info.si_errno = 0; in __send_signal_locked()
1095 q->info.si_code = SI_USER; in __send_signal_locked()
1096 q->info.si_pid = task_tgid_nr_ns(current, in __send_signal_locked()
1099 q->info.si_uid = in __send_signal_locked()
1105 clear_siginfo(&q->info); in __send_signal_locked()
1106 q->info.si_signo = sig; in __send_signal_locked()
1107 q->info.si_errno = 0; in __send_signal_locked()
1108 q->info.si_code = SI_KERNEL; in __send_signal_locked()
1109 q->info.si_pid = 0; in __send_signal_locked()
1110 q->info.si_uid = 0; in __send_signal_locked()
1113 copy_siginfo(&q->info, info); in __send_signal_locked()
1117 sig >= SIGRTMIN && info->si_code != SI_USER) { in __send_signal_locked()
1124 ret = -EAGAIN; in __send_signal_locked()
1136 sigaddset(&pending->signal, sig); in __send_signal_locked()
1138 /* Let multiprocess signals appear after on-going forks */ in __send_signal_locked()
1141 hlist_for_each_entry(delayed, &t->signal->multiprocess, node) { in __send_signal_locked()
1142 sigset_t *signal = &delayed->signal; in __send_signal_locked()
1161 switch (siginfo_layout(info->si_signo, info->si_code)) { in has_si_pid_and_uid()
1201 kuid_t uid = make_kuid(current_user_ns(), info->si_uid); in send_signal_locked()
1202 info->si_uid = from_kuid_munged(t_user_ns, uid); in send_signal_locked()
1207 force = (info->si_code == SI_KERNEL); in send_signal_locked()
1211 info->si_pid = 0; in send_signal_locked()
1226 exe_file, current->comm, signr); in print_fatal_signal()
1230 current->comm, signr); in print_fatal_signal()
1234 pr_info("code at %08lx: ", regs->ip); in print_fatal_signal()
1240 if (get_user(insn, (unsigned char *)(regs->ip + i))) in print_fatal_signal()
1259 __setup("print-fatal-signals=", setup_print_fatal_signals);
1265 int ret = -ESRCH; in do_send_sig_info()
1299 int sig = info->si_signo; in force_sig_info_to_task()
1301 spin_lock_irqsave(&t->sighand->siglock, flags); in force_sig_info_to_task()
1302 action = &t->sighand->action[sig-1]; in force_sig_info_to_task()
1303 ignored = action->sa.sa_handler == SIG_IGN; in force_sig_info_to_task()
1304 blocked = sigismember(&t->blocked, sig); in force_sig_info_to_task()
1306 action->sa.sa_handler = SIG_DFL; in force_sig_info_to_task()
1308 action->sa.sa_flags |= SA_IMMUTABLE; in force_sig_info_to_task()
1310 sigdelset(&t->blocked, sig); in force_sig_info_to_task()
1316 if (action->sa.sa_handler == SIG_DFL && in force_sig_info_to_task()
1317 (!t->ptrace || (handler == HANDLER_EXIT))) in force_sig_info_to_task()
1318 t->signal->flags &= ~SIGNAL_UNKILLABLE; in force_sig_info_to_task()
1323 spin_unlock_irqrestore(&t->sighand->siglock, flags); in force_sig_info_to_task()
1341 p->signal->group_stop_count = 0; in zap_other_threads()
1348 if (t->exit_state) in zap_other_threads()
1350 sigaddset(&t->pending.signal, SIGKILL); in zap_other_threads()
1364 sighand = rcu_dereference(tsk->sighand); in __lock_task_sighand()
1371 * initializes ->siglock: this slab can't go away, it has in __lock_task_sighand()
1372 * the same object type, ->siglock can't be reinitialized. in __lock_task_sighand()
1374 * We need to ensure that tsk->sighand is still the same in __lock_task_sighand()
1377 * must see ->sighand == NULL. in __lock_task_sighand()
1379 spin_lock_irqsave(&sighand->siglock, *flags); in __lock_task_sighand()
1380 if (likely(sighand == rcu_access_pointer(tsk->sighand))) in __lock_task_sighand()
1382 spin_unlock_irqrestore(&sighand->siglock, *flags); in __lock_task_sighand()
1395 sighand = rcu_dereference(task->sighand); in lockdep_assert_task_sighand_held()
1397 lockdep_assert_held(&sighand->siglock); in lockdep_assert_task_sighand_held()
1426 * - the caller must hold at least a readlock on tasklist_lock
1431 int ret = -ESRCH; in __kill_pgrp_info()
1438 * Otherwise we return the last err or -ESRCH if this in __kill_pgrp_info()
1451 int error = -ESRCH; in kill_pid_info_type()
1460 if (likely(!p || error != -ESRCH)) in kill_pid_info_type()
1489 return uid_eq(cred->euid, pcred->suid) || in kill_as_cred_perm()
1490 uid_eq(cred->euid, pcred->uid) || in kill_as_cred_perm()
1491 uid_eq(cred->uid, pcred->suid) || in kill_as_cred_perm()
1492 uid_eq(cred->uid, pcred->uid); in kill_as_cred_perm()
1526 int ret = -EINVAL; in kill_pid_usb_asyncio()
1540 ret = -ESRCH; in kill_pid_usb_asyncio()
1544 ret = -EPERM; in kill_pid_usb_asyncio()
1556 ret = -ESRCH; in kill_pid_usb_asyncio()
1567 * POSIX specifies that kill(-1,sig) is unspecified, but what we have
1578 /* -INT_MIN is undefined. Exclude this case to avoid a UBSAN warning */ in kill_something_info()
1580 return -ESRCH; in kill_something_info()
1583 if (pid != -1) { in kill_something_info()
1585 pid ? find_vpid(-pid) : task_pgrp(current)); in kill_something_info()
1596 if (err != -EPERM) in kill_something_info()
1600 ret = count ? retval : -ESRCH; in kill_something_info()
1618 return -EINVAL; in send_sig_info()
1795 info.si_perf_flags = sigismember(¤t->blocked, info.si_signo) ? in send_sig_perf()
1803 * force_sig_seccomp - signals the task to allow in-process syscall emulation
1805 * @reason: filter-supplied reason code to send to userland (via si_errno)
1904 signal = pending->signal; in __flush_itimer_signals()
1907 list_for_each_entry_safe(q, n, &pending->list, list) { in __flush_itimer_signals()
1908 int sig = q->info.si_signo; in __flush_itimer_signals()
1910 if (likely(q->info.si_code != SI_TIMER)) { in __flush_itimer_signals()
1914 list_del_init(&q->list); in __flush_itimer_signals()
1919 sigorsets(&pending->signal, &signal, &retain); in __flush_itimer_signals()
1926 guard(spinlock_irqsave)(&tsk->sighand->siglock); in flush_itimer_signals()
1927 __flush_itimer_signals(&tsk->pending); in flush_itimer_signals()
1928 __flush_itimer_signals(&tsk->signal->shared_pending); in flush_itimer_signals()
1933 struct ucounts *ucounts = sig_get_ucounts(current, -1, 0); in posixtimer_init_sigqueue()
1937 clear_siginfo(&q->info); in posixtimer_init_sigqueue()
1945 int sig = q->info.si_signo; in posixtimer_queue_sigqueue()
1948 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; in posixtimer_queue_sigqueue()
1949 list_add_tail(&q->list, &pending->list); in posixtimer_queue_sigqueue()
1950 sigaddset(&pending->signal, sig); in posixtimer_queue_sigqueue()
1958 * into t->pending).
1965 static inline struct task_struct *posixtimer_get_target(struct k_itimer *tmr) in posixtimer_get_target() argument
1967 struct task_struct *t = pid_task(tmr->it_pid, tmr->it_pid_type); in posixtimer_get_target()
1969 if (t && tmr->it_pid_type != PIDTYPE_PID && in posixtimer_get_target()
1970 same_thread_group(t, current) && !current->exit_state) in posixtimer_get_target()
1975 void posixtimer_send_sigqueue(struct k_itimer *tmr) in posixtimer_send_sigqueue() argument
1977 struct sigqueue *q = &tmr->sigq; in posixtimer_send_sigqueue()
1978 int sig = q->info.si_signo; in posixtimer_send_sigqueue()
1985 t = posixtimer_get_target(tmr); in posixtimer_send_sigqueue()
1993 * Update @tmr::sigqueue_seq for posix timer signals with sighand in posixtimer_send_sigqueue()
1996 tmr->it_sigqueue_seq = tmr->it_signal_seq; in posixtimer_send_sigqueue()
2001 * non-periodic timer. in posixtimer_send_sigqueue()
2003 tmr->it_sig_periodic = tmr->it_status == POSIX_TIMER_REQUEUE_PENDING; in posixtimer_send_sigqueue()
2008 if (!list_empty(&q->list)) { in posixtimer_send_sigqueue()
2030 if (tmr->it_sig_periodic) { in posixtimer_send_sigqueue()
2036 if (hlist_unhashed(&tmr->ignored_list)) { in posixtimer_send_sigqueue()
2044 } else if (!hlist_unhashed(&tmr->ignored_list)) { in posixtimer_send_sigqueue()
2054 hlist_del_init(&tmr->ignored_list); in posixtimer_send_sigqueue()
2055 posixtimer_putref(tmr); in posixtimer_send_sigqueue()
2060 if (unlikely(!list_empty(&q->list))) { in posixtimer_send_sigqueue()
2074 if (likely(hlist_unhashed(&tmr->ignored_list))) in posixtimer_send_sigqueue()
2077 hlist_del_init(&tmr->ignored_list); in posixtimer_send_sigqueue()
2079 posixtimer_queue_sigqueue(q, t, tmr->it_pid_type); in posixtimer_send_sigqueue()
2082 trace_signal_generate(sig, &q->info, t, tmr->it_pid_type != PIDTYPE_PID, result); in posixtimer_send_sigqueue()
2088 struct k_itimer *tmr = container_of(q, struct k_itimer, sigq); in posixtimer_sig_ignore() local
2092 * from a non-periodic timer, then just drop the reference in posixtimer_sig_ignore()
2095 if (tmr->it_signal && tmr->it_sig_periodic) in posixtimer_sig_ignore()
2096 hlist_add_head(&tmr->ignored_list, &tsk->signal->ignored_posix_timers); in posixtimer_sig_ignore()
2098 posixtimer_putref(tmr); in posixtimer_sig_ignore()
2103 struct hlist_head *head = &tsk->signal->ignored_posix_timers; in posixtimer_sig_unignore()
2105 struct k_itimer *tmr; in posixtimer_sig_unignore() local
2112 * lock ordering vs. tmr::it_lock. Just stick the sigqueue back and in posixtimer_sig_unignore()
2117 hlist_for_each_entry_safe(tmr, tmp , head, ignored_list) { in posixtimer_sig_unignore()
2121 * tmr::sigq.info.si_signo is immutable, so accessing it in posixtimer_sig_unignore()
2122 * without holding tmr::it_lock is safe. in posixtimer_sig_unignore()
2124 if (tmr->sigq.info.si_signo != sig) in posixtimer_sig_unignore()
2127 hlist_del_init(&tmr->ignored_list); in posixtimer_sig_unignore()
2130 if (WARN_ON_ONCE(!list_empty(&tmr->sigq.list))) in posixtimer_sig_unignore()
2138 target = posixtimer_get_target(tmr); in posixtimer_sig_unignore()
2140 posixtimer_queue_sigqueue(&tmr->sigq, target, tmr->it_pid_type); in posixtimer_sig_unignore()
2142 posixtimer_putref(tmr); in posixtimer_sig_unignore()
2154 WARN_ON(task->exit_state == 0); in do_notify_pidfd()
2156 __wake_up(&pid->wait_pidfd, TASK_NORMAL, 0, in do_notify_pidfd()
2165 * self-reaping.
2175 WARN_ON_ONCE(sig == -1); in do_notify_parent()
2180 WARN_ON_ONCE(!tsk->ptrace && in do_notify_parent()
2181 (tsk->group_leader != tsk || !thread_group_empty(tsk))); in do_notify_parent()
2184 * non-PIDFD_THREAD waiters. in do_notify_parent()
2194 if (tsk->parent_exec_id != READ_ONCE(tsk->parent->self_exec_id)) in do_notify_parent()
2213 info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(tsk->parent)); in do_notify_parent()
2214 info.si_uid = from_kuid_munged(task_cred_xxx(tsk->parent, user_ns), in do_notify_parent()
2219 info.si_utime = nsec_to_clock_t(utime + tsk->signal->utime); in do_notify_parent()
2220 info.si_stime = nsec_to_clock_t(stime + tsk->signal->stime); in do_notify_parent()
2222 info.si_status = tsk->exit_code & 0x7f; in do_notify_parent()
2223 if (tsk->exit_code & 0x80) in do_notify_parent()
2225 else if (tsk->exit_code & 0x7f) in do_notify_parent()
2229 info.si_status = tsk->exit_code >> 8; in do_notify_parent()
2232 psig = tsk->parent->sighand; in do_notify_parent()
2233 spin_lock_irqsave(&psig->siglock, flags); in do_notify_parent()
2234 if (!tsk->ptrace && sig == SIGCHLD && in do_notify_parent()
2235 (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN || in do_notify_parent()
2236 (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) { in do_notify_parent()
2246 * blocked sys_wait4 might now return -ECHILD. in do_notify_parent()
2249 * is implementation-defined: we do (if you don't want in do_notify_parent()
2253 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) in do_notify_parent()
2261 __send_signal_locked(sig, &info, tsk->parent, PIDTYPE_TGID, false); in do_notify_parent()
2262 __wake_up_parent(tsk, tsk->parent); in do_notify_parent()
2263 spin_unlock_irqrestore(&psig->siglock, flags); in do_notify_parent()
2269 * do_notify_parent_cldstop - notify parent of stopped/continued state change
2276 * If %true, @tsk reports to @tsk->parent which should be the ptracer.
2291 parent = tsk->parent; in do_notify_parent_cldstop()
2293 tsk = tsk->group_leader; in do_notify_parent_cldstop()
2294 parent = tsk->real_parent; in do_notify_parent_cldstop()
2318 info.si_status = tsk->signal->group_exit_code & 0x7f; in do_notify_parent_cldstop()
2321 info.si_status = tsk->exit_code & 0x7f; in do_notify_parent_cldstop()
2327 sighand = parent->sighand; in do_notify_parent_cldstop()
2328 spin_lock_irqsave(&sighand->siglock, flags); in do_notify_parent_cldstop()
2329 if (sighand->action[SIGCHLD-1].sa.sa_handler != SIG_IGN && in do_notify_parent_cldstop()
2330 !(sighand->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDSTOP)) in do_notify_parent_cldstop()
2336 spin_unlock_irqrestore(&sighand->siglock, flags); in do_notify_parent_cldstop()
2340 * This must be called with current->sighand->siglock held.
2343 * We always set current->last_siginfo while stopped here.
2345 * being ptrace-stopped vs being job-control-stopped.
2353 __releases(¤t->sighand->siglock) in ptrace_stop()
2354 __acquires(¤t->sighand->siglock) in ptrace_stop()
2367 spin_unlock_irq(¤t->sighand->siglock); in ptrace_stop()
2369 spin_lock_irq(¤t->sighand->siglock); in ptrace_stop()
2378 if (!current->ptrace || __fatal_signal_pending(current)) in ptrace_stop()
2382 current->jobctl |= JOBCTL_TRACED; in ptrace_stop()
2387 * Also, transition to TRACED and updates to ->jobctl should be in ptrace_stop()
2404 current->ptrace_message = message; in ptrace_stop()
2405 current->last_siginfo = info; in ptrace_stop()
2406 current->exit_code = exit_code; in ptrace_stop()
2413 * TASK_TRACED is entered - ignore it. in ptrace_stop()
2415 if (why == CLD_STOPPED && (current->jobctl & JOBCTL_STOP_PENDING)) in ptrace_stop()
2420 if (info && info->si_code >> 8 == PTRACE_EVENT_STOP) in ptrace_stop()
2426 spin_unlock_irq(¤t->sighand->siglock); in ptrace_stop()
2431 * While ptraced, there are two parents - the ptracer and in ptrace_stop()
2438 if (current->ptrace) in ptrace_stop()
2440 if (gstop_done && (!current->ptrace || ptrace_reparented(current))) in ptrace_stop()
2456 * ptracer's sleep. The preempt-disable section ensures that there in ptrace_stop()
2482 * any signal-sending on another CPU that wants to examine it. in ptrace_stop()
2484 spin_lock_irq(¤t->sighand->siglock); in ptrace_stop()
2485 exit_code = current->exit_code; in ptrace_stop()
2486 current->last_siginfo = NULL; in ptrace_stop()
2487 current->ptrace_message = 0; in ptrace_stop()
2488 current->exit_code = 0; in ptrace_stop()
2491 current->jobctl &= ~(JOBCTL_LISTENING | JOBCTL_PTRACE_FROZEN); in ptrace_stop()
2524 spin_lock_irq(¤t->sighand->siglock); in ptrace_notify()
2526 spin_unlock_irq(¤t->sighand->siglock); in ptrace_notify()
2531 * do_signal_stop - handle group stop for SIGSTOP and other stop signals
2545 * Must be called with @current->sighand->siglock held, which is released
2553 __releases(¤t->sighand->siglock) in do_signal_stop()
2555 struct signal_struct *sig = current->signal; in do_signal_stop()
2557 if (!(current->jobctl & JOBCTL_STOP_PENDING)) { in do_signal_stop()
2561 /* signr will be recorded in task->jobctl for retries */ in do_signal_stop()
2564 if (!likely(current->jobctl & JOBCTL_STOP_DEQUEUED) || in do_signal_stop()
2565 unlikely(sig->flags & SIGNAL_GROUP_EXIT) || in do_signal_stop()
2566 unlikely(sig->group_exec_task)) in do_signal_stop()
2587 if (!(sig->flags & SIGNAL_STOP_STOPPED)) in do_signal_stop()
2588 sig->group_exit_code = signr; in do_signal_stop()
2590 sig->group_stop_count = 0; in do_signal_stop()
2592 sig->group_stop_count++; in do_signal_stop()
2602 sig->group_stop_count++; in do_signal_stop()
2603 if (likely(!(t->ptrace & PT_SEIZED))) in do_signal_stop()
2611 if (likely(!current->ptrace)) { in do_signal_stop()
2622 current->jobctl |= JOBCTL_STOPPED; in do_signal_stop()
2624 spin_unlock_irq(¤t->sighand->siglock); in do_signal_stop()
2656 * do_jobctl_trap - take care of ptrace jobctl traps
2667 * Must be called with @current->sighand->siglock held, which may be
2668 * released and re-acquired before returning with intervening sleep.
2672 struct signal_struct *signal = current->signal; in do_jobctl_trap()
2673 int signr = current->jobctl & JOBCTL_STOP_SIGMASK; in do_jobctl_trap()
2675 if (current->ptrace & PT_SEIZED) { in do_jobctl_trap()
2676 if (!signal->group_stop_count && in do_jobctl_trap()
2677 !(signal->flags & SIGNAL_STOP_STOPPED)) in do_jobctl_trap()
2689 * do_freezer_trap - handle the freezer jobctl trap
2695 * Must be called with @current->sighand->siglock held,
2699 __releases(¤t->sighand->siglock) in do_freezer_trap()
2706 if ((current->jobctl & (JOBCTL_PENDING_MASK | JOBCTL_TRAP_FREEZE)) != in do_freezer_trap()
2708 spin_unlock_irq(¤t->sighand->siglock); in do_freezer_trap()
2715 * immediately (if there is a non-fatal signal pending), and in do_freezer_trap()
2720 spin_unlock_irq(¤t->sighand->siglock); in do_freezer_trap()
2744 current->jobctl |= JOBCTL_STOP_DEQUEUED; in ptrace_signal()
2757 if (signr != info->si_signo) { in ptrace_signal()
2759 info->si_signo = signr; in ptrace_signal()
2760 info->si_errno = 0; in ptrace_signal()
2761 info->si_code = SI_USER; in ptrace_signal()
2763 info->si_pid = task_pid_vnr(current->parent); in ptrace_signal()
2764 info->si_uid = from_kuid_munged(current_user_ns(), in ptrace_signal()
2765 task_uid(current->parent)); in ptrace_signal()
2770 if (sigismember(¤t->blocked, signr) || in ptrace_signal()
2781 switch (siginfo_layout(ksig->sig, ksig->info.si_code)) { in hide_si_addr_tag_bits()
2788 ksig->info.si_addr = arch_untagged_si_addr( in hide_si_addr_tag_bits()
2789 ksig->info.si_addr, ksig->sig, ksig->info.si_code); in hide_si_addr_tag_bits()
2803 struct sighand_struct *sighand = current->sighand; in get_signal()
2804 struct signal_struct *signal = current->signal; in get_signal()
2818 * Do this once, we can't return to user-mode if freezing() == T. in get_signal()
2825 spin_lock_irq(&sighand->siglock); in get_signal()
2832 if (unlikely(signal->flags & SIGNAL_CLD_MASK)) { in get_signal()
2835 if (signal->flags & SIGNAL_CLD_CONTINUED) in get_signal()
2840 signal->flags &= ~SIGNAL_CLD_MASK; in get_signal()
2842 spin_unlock_irq(&sighand->siglock); in get_signal()
2846 * always per-process and doesn't make whole lot of sense in get_signal()
2855 if (ptrace_reparented(current->group_leader)) in get_signal()
2856 do_notify_parent_cldstop(current->group_leader, in get_signal()
2868 if ((signal->flags & SIGNAL_GROUP_EXIT) || in get_signal()
2869 signal->group_exec_task) { in get_signal()
2871 sigdelset(¤t->pending.signal, SIGKILL); in get_signal()
2873 &sighand->action[SIGKILL-1]); in get_signal()
2877 * no need to initialize ksig->info/etc. in get_signal()
2882 if (unlikely(current->jobctl & JOBCTL_STOP_PENDING) && in get_signal()
2886 if (unlikely(current->jobctl & in get_signal()
2888 if (current->jobctl & JOBCTL_TRAP_MASK) { in get_signal()
2890 spin_unlock_irq(&sighand->siglock); in get_signal()
2891 } else if (current->jobctl & JOBCTL_TRAP_FREEZE) in get_signal()
2902 spin_unlock_irq(&sighand->siglock); in get_signal()
2914 signr = dequeue_synchronous_signal(&ksig->info); in get_signal()
2916 signr = dequeue_signal(¤t->blocked, &ksig->info, &type); in get_signal()
2921 if (unlikely(current->ptrace) && (signr != SIGKILL) && in get_signal()
2922 !(sighand->action[signr -1].sa.sa_flags & SA_IMMUTABLE)) { in get_signal()
2923 signr = ptrace_signal(signr, &ksig->info, type); in get_signal()
2928 ka = &sighand->action[signr-1]; in get_signal()
2931 trace_signal_deliver(signr, &ksig->info, ka); in get_signal()
2933 if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ in get_signal()
2935 if (ka->sa.sa_handler != SIG_DFL) { in get_signal()
2937 ksig->ka = *ka; in get_signal()
2939 if (ka->sa.sa_flags & SA_ONESHOT) in get_signal()
2940 ka->sa.sa_handler = SIG_DFL; in get_signal()
2942 break; /* will return non-zero "signr" value */ in get_signal()
2953 * Container-init gets no signals it doesn't want from same in get_signal()
2956 * Note that if global/container-init sees a sig_kernel_only() in get_signal()
2961 if (unlikely(signal->flags & SIGNAL_UNKILLABLE) && in get_signal()
2977 spin_unlock_irq(&sighand->siglock); in get_signal()
2984 spin_lock_irq(&sighand->siglock); in get_signal()
3000 spin_unlock_irq(&sighand->siglock); in get_signal()
3007 current->flags |= PF_SIGNALED; in get_signal()
3021 do_coredump(&ksig->info); in get_signal()
3030 if (current->flags & PF_USER_WORKER) in get_signal()
3039 spin_unlock_irq(&sighand->siglock); in get_signal()
3041 ksig->sig = signr; in get_signal()
3043 if (signr && !(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS)) in get_signal()
3050 * signal_delivered - called after signal delivery to update blocked signals
3052 * @stepping: nonzero if debugger single-step or block-step in use
3055 * delivered. It updates the blocked signals accordingly (@ksig->ka.sa.sa_mask
3057 * is set in @ksig->ka.sa.sa_flags. Tracing is notified.
3069 sigorsets(&blocked, ¤t->blocked, &ksig->ka.sa.sa_mask); in signal_delivered()
3070 if (!(ksig->ka.sa.sa_flags & SA_NODEFER)) in signal_delivered()
3071 sigaddset(&blocked, ksig->sig); in signal_delivered()
3073 if (current->sas_ss_flags & SS_AUTODISARM) in signal_delivered()
3082 force_sigsegv(ksig->sig); in signal_setup_done()
3089 * group-wide signal. Other threads should be notified now to take
3097 sigandsets(&retarget, &tsk->signal->shared_pending.signal, which); in retarget_shared_pending()
3102 if (t->flags & PF_EXITING) in retarget_shared_pending()
3105 if (!has_pending_signals(&retarget, &t->blocked)) in retarget_shared_pending()
3108 sigandsets(&retarget, &retarget, &t->blocked); in retarget_shared_pending()
3124 * @tsk is about to have PF_EXITING set - lock out users which in exit_signals()
3129 if (thread_group_empty(tsk) || (tsk->signal->flags & SIGNAL_GROUP_EXIT)) { in exit_signals()
3131 tsk->flags |= PF_EXITING; in exit_signals()
3136 spin_lock_irq(&tsk->sighand->siglock); in exit_signals()
3138 * From now this task is not visible for group-wide signals, in exit_signals()
3142 tsk->flags |= PF_EXITING; in exit_signals()
3149 unblocked = tsk->blocked; in exit_signals()
3153 if (unlikely(tsk->jobctl & JOBCTL_STOP_PENDING) && in exit_signals()
3157 spin_unlock_irq(&tsk->sighand->siglock); in exit_signals()
3175 * sys_restart_syscall - restart a system call
3179 struct restart_block *restart = ¤t->restart_block; in SYSCALL_DEFINE0()
3180 return restart->fn(restart); in SYSCALL_DEFINE0()
3185 return -EINTR; in do_no_restart_syscall()
3193 sigandnsets(&newblocked, newset, ¤t->blocked); in __set_task_blocked()
3196 tsk->blocked = *newset; in __set_task_blocked()
3201 * set_current_blocked - change current->blocked mask
3204 * It is wrong to change ->blocked directly, this helper should be used
3219 * to do. The current->blocked shouldn't be modified by other task. in __set_current_blocked()
3221 if (sigequalsets(&tsk->blocked, newset)) in __set_current_blocked()
3224 spin_lock_irq(&tsk->sighand->siglock); in __set_current_blocked()
3226 spin_unlock_irq(&tsk->sighand->siglock); in __set_current_blocked()
3233 * NOTE! Unlike the user-mode sys_sigprocmask(), the kernel
3242 /* Lockless, only current can change ->blocked, never from irq */ in sigprocmask()
3244 *oldset = tsk->blocked; in sigprocmask()
3248 sigorsets(&newset, &tsk->blocked, set); in sigprocmask()
3251 sigandnsets(&newset, &tsk->blocked, set); in sigprocmask()
3257 return -EINVAL; in sigprocmask()
3266 * The api helps set app-provided sigmasks.
3281 return -EINVAL; in set_user_sigmask()
3283 return -EFAULT; in set_user_sigmask()
3286 current->saved_sigmask = current->blocked; in set_user_sigmask()
3301 return -EINVAL; in set_compat_user_sigmask()
3303 return -EFAULT; in set_compat_user_sigmask()
3306 current->saved_sigmask = current->blocked; in set_compat_user_sigmask()
3314 * sys_rt_sigprocmask - change the list of currently blocked signals
3315 * @how: whether to add, remove, or set signals
3317 * @oset: previous value of signal mask if non-null
3328 return -EINVAL; in SYSCALL_DEFINE4()
3330 old_set = current->blocked; in SYSCALL_DEFINE4()
3334 return -EFAULT; in SYSCALL_DEFINE4()
3344 return -EFAULT; in SYSCALL_DEFINE4()
3354 sigset_t old_set = current->blocked; in COMPAT_SYSCALL_DEFINE4()
3358 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
3364 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3377 spin_lock_irq(¤t->sighand->siglock); in do_sigpending()
3378 sigorsets(set, ¤t->pending.signal, in do_sigpending()
3379 ¤t->signal->shared_pending.signal); in do_sigpending()
3380 spin_unlock_irq(¤t->sighand->siglock); in do_sigpending()
3383 sigandsets(set, ¤t->blocked, set); in do_sigpending()
3387 * sys_rt_sigpending - examine a pending signal that has been raised
3397 return -EINVAL; in SYSCALL_DEFINE2()
3402 return -EFAULT; in SYSCALL_DEFINE2()
3414 return -EINVAL; in COMPAT_SYSCALL_DEFINE2()
3506 return -EFAULT; in copy_siginfo_to_user()
3508 return -EFAULT; in copy_siginfo_to_user()
3515 if (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) { in post_copy_siginfo_from_user()
3526 return -EFAULT; in post_copy_siginfo_from_user()
3529 return -E2BIG; in post_copy_siginfo_from_user()
3539 return -EFAULT; in __copy_siginfo_from_user()
3540 to->si_signo = signo; in __copy_siginfo_from_user()
3547 return -EFAULT; in copy_siginfo_from_user()
3553 * copy_siginfo_to_external32 - copy a kernel siginfo into a compat user siginfo
3567 to->si_signo = from->si_signo; in copy_siginfo_to_external32()
3568 to->si_errno = from->si_errno; in copy_siginfo_to_external32()
3569 to->si_code = from->si_code; in copy_siginfo_to_external32()
3570 switch(siginfo_layout(from->si_signo, from->si_code)) { in copy_siginfo_to_external32()
3572 to->si_pid = from->si_pid; in copy_siginfo_to_external32()
3573 to->si_uid = from->si_uid; in copy_siginfo_to_external32()
3576 to->si_tid = from->si_tid; in copy_siginfo_to_external32()
3577 to->si_overrun = from->si_overrun; in copy_siginfo_to_external32()
3578 to->si_int = from->si_int; in copy_siginfo_to_external32()
3581 to->si_band = from->si_band; in copy_siginfo_to_external32()
3582 to->si_fd = from->si_fd; in copy_siginfo_to_external32()
3585 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3588 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3589 to->si_trapno = from->si_trapno; in copy_siginfo_to_external32()
3592 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3593 to->si_addr_lsb = from->si_addr_lsb; in copy_siginfo_to_external32()
3596 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3597 to->si_lower = ptr_to_compat(from->si_lower); in copy_siginfo_to_external32()
3598 to->si_upper = ptr_to_compat(from->si_upper); in copy_siginfo_to_external32()
3601 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3602 to->si_pkey = from->si_pkey; in copy_siginfo_to_external32()
3605 to->si_addr = ptr_to_compat(from->si_addr); in copy_siginfo_to_external32()
3606 to->si_perf_data = from->si_perf_data; in copy_siginfo_to_external32()
3607 to->si_perf_type = from->si_perf_type; in copy_siginfo_to_external32()
3608 to->si_perf_flags = from->si_perf_flags; in copy_siginfo_to_external32()
3611 to->si_pid = from->si_pid; in copy_siginfo_to_external32()
3612 to->si_uid = from->si_uid; in copy_siginfo_to_external32()
3613 to->si_status = from->si_status; in copy_siginfo_to_external32()
3614 to->si_utime = from->si_utime; in copy_siginfo_to_external32()
3615 to->si_stime = from->si_stime; in copy_siginfo_to_external32()
3618 to->si_pid = from->si_pid; in copy_siginfo_to_external32()
3619 to->si_uid = from->si_uid; in copy_siginfo_to_external32()
3620 to->si_int = from->si_int; in copy_siginfo_to_external32()
3623 to->si_call_addr = ptr_to_compat(from->si_call_addr); in copy_siginfo_to_external32()
3624 to->si_syscall = from->si_syscall; in copy_siginfo_to_external32()
3625 to->si_arch = from->si_arch; in copy_siginfo_to_external32()
3637 return -EFAULT; in __copy_siginfo_to_user32()
3645 to->si_signo = from->si_signo; in post_copy_siginfo_from_user32()
3646 to->si_errno = from->si_errno; in post_copy_siginfo_from_user32()
3647 to->si_code = from->si_code; in post_copy_siginfo_from_user32()
3648 switch(siginfo_layout(from->si_signo, from->si_code)) { in post_copy_siginfo_from_user32()
3650 to->si_pid = from->si_pid; in post_copy_siginfo_from_user32()
3651 to->si_uid = from->si_uid; in post_copy_siginfo_from_user32()
3654 to->si_tid = from->si_tid; in post_copy_siginfo_from_user32()
3655 to->si_overrun = from->si_overrun; in post_copy_siginfo_from_user32()
3656 to->si_int = from->si_int; in post_copy_siginfo_from_user32()
3659 to->si_band = from->si_band; in post_copy_siginfo_from_user32()
3660 to->si_fd = from->si_fd; in post_copy_siginfo_from_user32()
3663 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3666 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3667 to->si_trapno = from->si_trapno; in post_copy_siginfo_from_user32()
3670 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3671 to->si_addr_lsb = from->si_addr_lsb; in post_copy_siginfo_from_user32()
3674 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3675 to->si_lower = compat_ptr(from->si_lower); in post_copy_siginfo_from_user32()
3676 to->si_upper = compat_ptr(from->si_upper); in post_copy_siginfo_from_user32()
3679 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3680 to->si_pkey = from->si_pkey; in post_copy_siginfo_from_user32()
3683 to->si_addr = compat_ptr(from->si_addr); in post_copy_siginfo_from_user32()
3684 to->si_perf_data = from->si_perf_data; in post_copy_siginfo_from_user32()
3685 to->si_perf_type = from->si_perf_type; in post_copy_siginfo_from_user32()
3686 to->si_perf_flags = from->si_perf_flags; in post_copy_siginfo_from_user32()
3689 to->si_pid = from->si_pid; in post_copy_siginfo_from_user32()
3690 to->si_uid = from->si_uid; in post_copy_siginfo_from_user32()
3691 to->si_status = from->si_status; in post_copy_siginfo_from_user32()
3694 to->si_utime = from->_sifields._sigchld_x32._utime; in post_copy_siginfo_from_user32()
3695 to->si_stime = from->_sifields._sigchld_x32._stime; in post_copy_siginfo_from_user32()
3699 to->si_utime = from->si_utime; in post_copy_siginfo_from_user32()
3700 to->si_stime = from->si_stime; in post_copy_siginfo_from_user32()
3704 to->si_pid = from->si_pid; in post_copy_siginfo_from_user32()
3705 to->si_uid = from->si_uid; in post_copy_siginfo_from_user32()
3706 to->si_int = from->si_int; in post_copy_siginfo_from_user32()
3709 to->si_call_addr = compat_ptr(from->si_call_addr); in post_copy_siginfo_from_user32()
3710 to->si_syscall = from->si_syscall; in post_copy_siginfo_from_user32()
3711 to->si_arch = from->si_arch; in post_copy_siginfo_from_user32()
3723 return -EFAULT; in __copy_siginfo_from_user32()
3735 return -EFAULT; in copy_siginfo_from_user32()
3742 * do_sigtimedwait - wait for queued signals specified in @which
3744 * @info: if non-null, the signal's siginfo is returned here
3758 return -EINVAL; in do_sigtimedwait()
3769 spin_lock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3778 tsk->real_blocked = tsk->blocked; in do_sigtimedwait()
3779 sigandsets(&tsk->blocked, &tsk->blocked, &mask); in do_sigtimedwait()
3781 spin_unlock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3784 ret = schedule_hrtimeout_range(to, tsk->timer_slack_ns, in do_sigtimedwait()
3786 spin_lock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3787 __set_task_blocked(tsk, &tsk->real_blocked); in do_sigtimedwait()
3788 sigemptyset(&tsk->real_blocked); in do_sigtimedwait()
3791 spin_unlock_irq(&tsk->sighand->siglock); in do_sigtimedwait()
3795 return ret ? -EINTR : -EAGAIN; in do_sigtimedwait()
3799 * sys_rt_sigtimedwait - synchronously wait for queued signals specified
3802 * @uinfo: if non-null, the signal's siginfo is returned here
3818 return -EINVAL; in SYSCALL_DEFINE4()
3821 return -EFAULT; in SYSCALL_DEFINE4()
3825 return -EFAULT; in SYSCALL_DEFINE4()
3832 ret = -EFAULT; in SYSCALL_DEFINE4()
3850 return -EINVAL; in SYSCALL_DEFINE4()
3853 return -EFAULT; in SYSCALL_DEFINE4()
3857 return -EFAULT; in SYSCALL_DEFINE4()
3864 ret = -EFAULT; in SYSCALL_DEFINE4()
3882 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
3885 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3889 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3896 ret = -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3913 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
3916 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3920 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3927 ret = -EFAULT; in COMPAT_SYSCALL_DEFINE4()
3939 info->si_signo = sig; in prepare_kill_siginfo()
3940 info->si_errno = 0; in prepare_kill_siginfo()
3941 info->si_code = (type == PIDTYPE_PID) ? SI_TKILL : SI_USER; in prepare_kill_siginfo()
3942 info->si_pid = task_tgid_vnr(current); in prepare_kill_siginfo()
3943 info->si_uid = from_kuid_munged(current_user_ns(), current_uid()); in prepare_kill_siginfo()
3947 * sys_kill - send a signal to a process
3975 p = p->parent; in access_pidfd_pidns()
3987 * conversions here. Note, this is a stop-gap measure and should not be in copy_siginfo_from_user_any()
4013 * sys_pidfd_send_signal - Signal a process through a pidfd
4034 /* Enforce flags be set to 0 until we add an extension. */ in SYSCALL_DEFINE4()
4036 return -EINVAL; in SYSCALL_DEFINE4()
4040 return -EINVAL; in SYSCALL_DEFINE4()
4044 return -EBADF; in SYSCALL_DEFINE4()
4052 return -EINVAL; in SYSCALL_DEFINE4()
4057 if (fd_file(f)->f_flags & PIDFD_THREAD) in SYSCALL_DEFINE4()
4079 return -EINVAL; in SYSCALL_DEFINE4()
4084 return -EPERM; in SYSCALL_DEFINE4()
4099 int error = -ESRCH; in do_send_specific()
4116 if (unlikely(error == -ESRCH)) in do_send_specific()
4135 * sys_tgkill - send signal to one specific thread
4140 * This syscall also checks the @tgid and returns -ESRCH even if the PID
4148 return -EINVAL; in SYSCALL_DEFINE3()
4154 * sys_tkill - send signal to one specific task
4164 return -EINVAL; in SYSCALL_DEFINE2()
4174 if ((info->si_code >= 0 || info->si_code == SI_TKILL) && in do_rt_sigqueueinfo()
4176 return -EPERM; in do_rt_sigqueueinfo()
4183 * sys_rt_sigqueueinfo - send signal information to a signal
4216 return -EINVAL; in do_rt_tgsigqueueinfo()
4221 if ((info->si_code >= 0 || info->si_code == SI_TKILL) && in do_rt_tgsigqueueinfo()
4223 return -EPERM; in do_rt_tgsigqueueinfo()
4258 spin_lock_irq(¤t->sighand->siglock); in kernel_sigaction()
4259 current->sighand->action[sig - 1].sa.sa_handler = action; in kernel_sigaction()
4266 flush_sigqueue_mask(current, &mask, ¤t->signal->shared_pending); in kernel_sigaction()
4267 flush_sigqueue_mask(current, &mask, ¤t->pending); in kernel_sigaction()
4270 spin_unlock_irq(¤t->sighand->siglock); in kernel_sigaction()
4286 return -EINVAL; in do_sigaction()
4288 k = &p->sighand->action[sig-1]; in do_sigaction()
4290 spin_lock_irq(&p->sighand->siglock); in do_sigaction()
4291 if (k->sa.sa_flags & SA_IMMUTABLE) { in do_sigaction()
4292 spin_unlock_irq(&p->sighand->siglock); in do_sigaction()
4293 return -EINVAL; in do_sigaction()
4306 * support for flag bits and to allow the kernel to use non-uapi bits in do_sigaction()
4310 act->sa.sa_flags &= UAPI_SA_FLAGS; in do_sigaction()
4312 oact->sa.sa_flags &= UAPI_SA_FLAGS; in do_sigaction()
4317 bool was_ignored = k->sa.sa_handler == SIG_IGN; in do_sigaction()
4319 sigdelsetmask(&act->sa.sa_mask, in do_sigaction()
4336 flush_sigqueue_mask(p, &mask, &p->signal->shared_pending); in do_sigaction()
4338 flush_sigqueue_mask(p, &mask, &t->pending); in do_sigaction()
4344 spin_unlock_irq(&p->sighand->siglock); in do_sigaction()
4350 __acquires(¤t->sighand->siglock) in sigaltstack_lock()
4352 spin_lock_irq(¤t->sighand->siglock); in sigaltstack_lock()
4356 __releases(¤t->sighand->siglock) in sigaltstack_unlock()
4358 spin_unlock_irq(¤t->sighand->siglock); in sigaltstack_unlock()
4374 oss->ss_sp = (void __user *) t->sas_ss_sp; in do_sigaltstack()
4375 oss->ss_size = t->sas_ss_size; in do_sigaltstack()
4376 oss->ss_flags = sas_ss_flags(sp) | in do_sigaltstack()
4377 (current->sas_ss_flags & SS_FLAG_BITS); in do_sigaltstack()
4381 void __user *ss_sp = ss->ss_sp; in do_sigaltstack()
4382 size_t ss_size = ss->ss_size; in do_sigaltstack()
4383 unsigned ss_flags = ss->ss_flags; in do_sigaltstack()
4387 return -EPERM; in do_sigaltstack()
4392 return -EINVAL; in do_sigaltstack()
4398 if (t->sas_ss_sp == (unsigned long)ss_sp && in do_sigaltstack()
4399 t->sas_ss_size == ss_size && in do_sigaltstack()
4400 t->sas_ss_flags == ss_flags) in do_sigaltstack()
4409 ret = -ENOMEM; in do_sigaltstack()
4411 ret = -ENOMEM; in do_sigaltstack()
4414 t->sas_ss_sp = (unsigned long) ss_sp; in do_sigaltstack()
4415 t->sas_ss_size = ss_size; in do_sigaltstack()
4416 t->sas_ss_flags = ss_flags; in do_sigaltstack()
4428 return -EFAULT; in SYSCALL_DEFINE2()
4433 err = -EFAULT; in SYSCALL_DEFINE2()
4441 return -EFAULT; in restore_altstack()
4451 int err = __put_user((void __user *)t->sas_ss_sp, &uss->ss_sp) | in __save_altstack()
4452 __put_user(t->sas_ss_flags, &uss->ss_flags) | in __save_altstack()
4453 __put_user(t->sas_ss_size, &uss->ss_size); in __save_altstack()
4467 return -EFAULT; in do_compat_sigaltstack()
4482 ret = -EFAULT; in do_compat_sigaltstack()
4497 /* squash all but -EFAULT for now */ in compat_restore_altstack()
4498 return err == -EFAULT ? err : 0; in compat_restore_altstack()
4505 err = __put_user(ptr_to_compat((void __user *)t->sas_ss_sp), in __compat_save_altstack()
4506 &uss->ss_sp) | in __compat_save_altstack()
4507 __put_user(t->sas_ss_flags, &uss->ss_flags) | in __compat_save_altstack()
4508 __put_user(t->sas_ss_size, &uss->ss_size); in __compat_save_altstack()
4516 * sys_sigpending - examine pending signals
4524 return -EINVAL; in SYSCALL_DEFINE1()
4529 return -EFAULT; in SYSCALL_DEFINE1()
4549 * sys_sigprocmask - examine and change blocked signals
4550 * @how: whether to add, remove, or set signals
4551 * @nset: signals to add or remove (if non-null)
4552 * @oset: previous value of signal mask if non-null
4564 old_set = current->blocked.sig[0]; in SYSCALL_DEFINE3()
4568 return -EFAULT; in SYSCALL_DEFINE3()
4570 new_blocked = current->blocked; in SYSCALL_DEFINE3()
4583 return -EINVAL; in SYSCALL_DEFINE3()
4591 return -EFAULT; in SYSCALL_DEFINE3()
4600 * sys_rt_sigaction - alter an action taken by a process
4616 return -EINVAL; in SYSCALL_DEFINE4()
4619 return -EFAULT; in SYSCALL_DEFINE4()
4626 return -EFAULT; in SYSCALL_DEFINE4()
4644 return -EINVAL; in COMPAT_SYSCALL_DEFINE4()
4648 ret = get_user(handler, &act->sa_handler); in COMPAT_SYSCALL_DEFINE4()
4651 ret |= get_user(restorer, &act->sa_restorer); in COMPAT_SYSCALL_DEFINE4()
4654 ret |= get_compat_sigset(&new_ka.sa.sa_mask, &act->sa_mask); in COMPAT_SYSCALL_DEFINE4()
4655 ret |= get_user(new_ka.sa.sa_flags, &act->sa_flags); in COMPAT_SYSCALL_DEFINE4()
4657 return -EFAULT; in COMPAT_SYSCALL_DEFINE4()
4663 &oact->sa_handler); in COMPAT_SYSCALL_DEFINE4()
4664 ret |= put_compat_sigset(&oact->sa_mask, &old_ka.sa.sa_mask, in COMPAT_SYSCALL_DEFINE4()
4665 sizeof(oact->sa_mask)); in COMPAT_SYSCALL_DEFINE4()
4666 ret |= put_user(old_ka.sa.sa_flags, &oact->sa_flags); in COMPAT_SYSCALL_DEFINE4()
4669 &oact->sa_restorer); in COMPAT_SYSCALL_DEFINE4()
4688 __get_user(new_ka.sa.sa_handler, &act->sa_handler) || in SYSCALL_DEFINE3()
4689 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) || in SYSCALL_DEFINE3()
4690 __get_user(new_ka.sa.sa_flags, &act->sa_flags) || in SYSCALL_DEFINE3()
4691 __get_user(mask, &act->sa_mask)) in SYSCALL_DEFINE3()
4692 return -EFAULT; in SYSCALL_DEFINE3()
4703 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || in SYSCALL_DEFINE3()
4704 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) || in SYSCALL_DEFINE3()
4705 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || in SYSCALL_DEFINE3()
4706 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) in SYSCALL_DEFINE3()
4707 return -EFAULT; in SYSCALL_DEFINE3()
4725 __get_user(handler, &act->sa_handler) || in COMPAT_SYSCALL_DEFINE3()
4726 __get_user(restorer, &act->sa_restorer) || in COMPAT_SYSCALL_DEFINE3()
4727 __get_user(new_ka.sa.sa_flags, &act->sa_flags) || in COMPAT_SYSCALL_DEFINE3()
4728 __get_user(mask, &act->sa_mask)) in COMPAT_SYSCALL_DEFINE3()
4729 return -EFAULT; in COMPAT_SYSCALL_DEFINE3()
4744 &oact->sa_handler) || in COMPAT_SYSCALL_DEFINE3()
4746 &oact->sa_restorer) || in COMPAT_SYSCALL_DEFINE3()
4747 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || in COMPAT_SYSCALL_DEFINE3()
4748 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) in COMPAT_SYSCALL_DEFINE3()
4749 return -EFAULT; in COMPAT_SYSCALL_DEFINE3()
4763 return current->blocked.sig[0]; in SYSCALL_DEFINE0()
4768 int old = current->blocked.sig[0]; in SYSCALL_DEFINE1()
4805 return -ERESTARTNOHAND; in SYSCALL_DEFINE0()
4812 current->saved_sigmask = current->blocked; in sigsuspend()
4820 return -ERESTARTNOHAND; in sigsuspend()
4824 * sys_rt_sigsuspend - replace the signal mask for a value with the
4835 return -EINVAL; in SYSCALL_DEFINE2()
4838 return -EFAULT; in SYSCALL_DEFINE2()
4849 return -EINVAL; in COMPAT_SYSCALL_DEFINE2()
4852 return -EFAULT; in COMPAT_SYSCALL_DEFINE2()
4956 .procname = "exception-trace",
4983 * kdb_send_sig - Allows kdb to send signals without exposing
4992 if (!spin_trylock(&t->sighand->siglock)) { in kdb_send_sig()
5001 spin_unlock(&t->sighand->siglock); in kdb_send_sig()
5011 spin_unlock(&t->sighand->siglock); in kdb_send_sig()
5014 sig, t->pid); in kdb_send_sig()
5016 kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid); in kdb_send_sig()