Lines Matching refs:sig

69 static void __user *sig_handler(struct task_struct *t, int sig)  in sig_handler()  argument
71 return t->sighand->action[sig - 1].sa.sa_handler; in sig_handler()
74 static inline bool sig_handler_ignored(void __user *handler, int sig) in sig_handler_ignored() argument
78 (handler == SIG_DFL && sig_kernel_ignore(sig)); in sig_handler_ignored()
81 static bool sig_task_ignored(struct task_struct *t, int sig, bool force) in sig_task_ignored() argument
85 handler = sig_handler(t, sig); in sig_task_ignored()
88 if (unlikely(is_global_init(t) && sig_kernel_only(sig))) in sig_task_ignored()
92 handler == SIG_DFL && !(force && sig_kernel_only(sig))) in sig_task_ignored()
100 return sig_handler_ignored(handler, sig); in sig_task_ignored()
103 static bool sig_ignored(struct task_struct *t, int sig, bool force) in sig_ignored() argument
110 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) in sig_ignored()
118 if (t->ptrace && sig != SIGKILL) in sig_ignored()
121 return sig_task_ignored(t, sig, force); in sig_ignored()
136 ready |= signal->sig[i] &~ blocked->sig[i]; in has_pending_signals()
139 case 4: ready = signal->sig[3] &~ blocked->sig[3]; in has_pending_signals()
140 ready |= signal->sig[2] &~ blocked->sig[2]; in has_pending_signals()
141 ready |= signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
142 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
145 case 2: ready = signal->sig[1] &~ blocked->sig[1]; in has_pending_signals()
146 ready |= signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
149 case 1: ready = signal->sig[0] &~ blocked->sig[0]; in has_pending_signals()
212 int sig = 0; in next_signal() local
214 s = pending->signal.sig; in next_signal()
215 m = mask->sig; in next_signal()
225 sig = ffz(~x) + 1; in next_signal()
226 return sig; in next_signal()
235 sig = ffz(~x) + i*_NSIG_BPW + 1; in next_signal()
244 sig = ffz(~x) + _NSIG_BPW + 1; in next_signal()
252 return sig; in next_signal()
255 static inline void print_dropped_signal(int sig) in print_dropped_signal() argument
266 current->comm, current->pid, sig); in print_dropped_signal()
369 struct signal_struct *sig = task->signal; in task_participate_group_stop() local
379 if (!WARN_ON_ONCE(sig->group_stop_count == 0)) in task_participate_group_stop()
380 sig->group_stop_count--; in task_participate_group_stop()
386 if (!sig->group_stop_count && !(sig->flags & SIGNAL_STOP_STOPPED)) { in task_participate_group_stop()
387 signal_set_stop_flags(sig, SIGNAL_STOP_STOPPED); in task_participate_group_stop()
396 struct signal_struct *sig = current->signal; in task_join_group_stop() local
398 if (sig->group_stop_count) { in task_join_group_stop()
399 sig->group_stop_count++; in task_join_group_stop()
401 } else if (!(sig->flags & SIGNAL_STOP_STOPPED)) in task_join_group_stop()
414 __sigqueue_alloc(int sig, struct task_struct *t, gfp_t gfp_flags, in __sigqueue_alloc() argument
440 print_dropped_signal(sig); in __sigqueue_alloc()
501 int sig = q->info.si_signo; in __flush_itimer_signals() local
504 sigaddset(&retain, sig); in __flush_itimer_signals()
506 sigdelset(&signal, sig); in __flush_itimer_signals()
558 bool unhandled_signal(struct task_struct *tsk, int sig) in unhandled_signal() argument
560 void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler; in unhandled_signal()
575 static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info, in collect_signal() argument
585 if (q->info.si_signo == sig) { in collect_signal()
592 sigdelset(&list->signal, sig); in collect_signal()
612 info->si_signo = sig; in collect_signal()
623 int sig = next_signal(pending, mask); in __dequeue_signal() local
625 if (sig) in __dequeue_signal()
626 collect_signal(sig, pending, info, resched_timer); in __dequeue_signal()
627 return sig; in __dequeue_signal()
726 if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK)) in dequeue_synchronous_signal()
841 static int check_kill_permission(int sig, struct kernel_siginfo *info, in check_kill_permission() argument
847 if (!valid_signal(sig)) in check_kill_permission()
853 error = audit_signal_info(sig, t); /* Let audit system see the signal */ in check_kill_permission()
859 switch (sig) { in check_kill_permission()
874 return security_task_kill(t, info, sig, NULL); in check_kill_permission()
913 static bool prepare_signal(int sig, struct task_struct *p, bool force) in prepare_signal() argument
921 return sig == SIGKILL; in prepare_signal()
926 } else if (sig_kernel_stop(sig)) { in prepare_signal()
934 } else if (sig == SIGCONT) { in prepare_signal()
977 return !sig_ignored(p, sig, force); in prepare_signal()
988 static inline bool wants_signal(int sig, struct task_struct *p) in wants_signal() argument
990 if (sigismember(&p->blocked, sig)) in wants_signal()
996 if (sig == SIGKILL) in wants_signal()
1005 static void complete_signal(int sig, struct task_struct *p, enum pid_type type) in complete_signal() argument
1015 if (wants_signal(sig, p)) in complete_signal()
1028 while (!wants_signal(sig, t)) { in complete_signal()
1045 if (sig_fatal(p, sig) && in complete_signal()
1047 !sigismember(&t->real_blocked, sig) && in complete_signal()
1048 (sig == SIGKILL || !p->ptrace)) { in complete_signal()
1052 if (!sig_kernel_coredump(sig)) { in complete_signal()
1060 signal->group_exit_code = sig; in complete_signal()
1076 signal_wake_up(t, sig == SIGKILL); in complete_signal()
1080 static inline bool legacy_queue(struct sigpending *signals, int sig) in legacy_queue() argument
1082 return (sig < SIGRTMIN) && sigismember(&signals->signal, sig); in legacy_queue()
1085 static int __send_signal_locked(int sig, struct kernel_siginfo *info, in __send_signal_locked() argument
1096 if (!prepare_signal(sig, t, force)) in __send_signal_locked()
1106 if (legacy_queue(pending, sig)) in __send_signal_locked()
1113 if ((sig == SIGKILL) || (t->flags & PF_KTHREAD)) in __send_signal_locked()
1125 if (sig < SIGRTMIN) in __send_signal_locked()
1130 q = __sigqueue_alloc(sig, t, GFP_ATOMIC, override_rlimit, 0); in __send_signal_locked()
1137 q->info.si_signo = sig; in __send_signal_locked()
1150 q->info.si_signo = sig; in __send_signal_locked()
1161 sig >= SIGRTMIN && info->si_code != SI_USER) { in __send_signal_locked()
1179 signalfd_notify(t, sig); in __send_signal_locked()
1180 sigaddset(&pending->signal, sig); in __send_signal_locked()
1188 if (sig == SIGCONT) in __send_signal_locked()
1190 else if (sig_kernel_stop(sig)) in __send_signal_locked()
1192 sigaddset(signal, sig); in __send_signal_locked()
1196 complete_signal(sig, t, type); in __send_signal_locked()
1198 trace_signal_generate(sig, info, t, type != PIDTYPE_PID, result); in __send_signal_locked()
1226 int send_signal_locked(int sig, struct kernel_siginfo *info, in send_signal_locked() argument
1259 return __send_signal_locked(sig, info, t, type, force); in send_signal_locked()
1305 int do_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p, in do_send_sig_info() argument
1312 ret = send_signal_locked(sig, info, p, type); in do_send_sig_info()
1343 int sig = info->si_signo; in force_sig_info_to_task() local
1346 action = &t->sighand->action[sig-1]; in force_sig_info_to_task()
1348 blocked = sigismember(&t->blocked, sig); in force_sig_info_to_task()
1354 sigdelset(&t->blocked, sig); in force_sig_info_to_task()
1365 ret = send_signal_locked(sig, info, t, PIDTYPE_PID); in force_sig_info_to_task()
1452 int group_send_sig_info(int sig, struct kernel_siginfo *info, in group_send_sig_info() argument
1458 ret = check_kill_permission(sig, info, p); in group_send_sig_info()
1461 if (!ret && sig) in group_send_sig_info()
1462 ret = do_send_sig_info(sig, info, p, type); in group_send_sig_info()
1472 int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp) in __kill_pgrp_info() argument
1480 int err = group_send_sig_info(sig, info, p, PIDTYPE_PGID); in __kill_pgrp_info()
1487 int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid) in kill_pid_info() argument
1496 error = group_send_sig_info(sig, info, p, PIDTYPE_TGID); in kill_pid_info()
1509 static int kill_proc_info(int sig, struct kernel_siginfo *info, pid_t pid) in kill_proc_info() argument
1513 error = kill_pid_info(sig, info, find_vpid(pid)); in kill_proc_info()
1554 int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr, in kill_pid_usb_asyncio() argument
1562 if (!valid_signal(sig)) in kill_pid_usb_asyncio()
1566 info.si_signo = sig; in kill_pid_usb_asyncio()
1581 ret = security_task_kill(p, &info, sig, cred); in kill_pid_usb_asyncio()
1585 if (sig) { in kill_pid_usb_asyncio()
1587 ret = __send_signal_locked(sig, &info, p, PIDTYPE_TGID, false); in kill_pid_usb_asyncio()
1605 static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid) in kill_something_info() argument
1610 return kill_proc_info(sig, info, pid); in kill_something_info()
1618 ret = __kill_pgrp_info(sig, info, in kill_something_info()
1627 int err = group_send_sig_info(sig, info, p, in kill_something_info()
1645 int send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p) in send_sig_info() argument
1651 if (!valid_signal(sig)) in send_sig_info()
1654 return do_send_sig_info(sig, info, p, PIDTYPE_PID); in send_sig_info()
1662 send_sig(int sig, struct task_struct *p, int priv) in send_sig() argument
1664 return send_sig_info(sig, __si_special(priv), p); in send_sig()
1668 void force_sig(int sig) in force_sig() argument
1673 info.si_signo = sig; in force_sig()
1682 void force_fatal_sig(int sig) in force_fatal_sig() argument
1687 info.si_signo = sig; in force_fatal_sig()
1695 void force_exit_sig(int sig) in force_exit_sig() argument
1700 info.si_signo = sig; in force_exit_sig()
1714 void force_sigsegv(int sig) in force_sigsegv() argument
1716 if (sig == SIGSEGV) in force_sigsegv()
1722 int force_sig_fault_to_task(int sig, int code, void __user *addr in force_sig_fault_to_task() argument
1729 info.si_signo = sig; in force_sig_fault_to_task()
1741 int force_sig_fault(int sig, int code, void __user *addr in force_sig_fault() argument
1744 return force_sig_fault_to_task(sig, code, addr in force_sig_fault()
1748 int send_sig_fault(int sig, int code, void __user *addr in send_sig_fault() argument
1755 info.si_signo = sig; in send_sig_fault()
1892 int force_sig_fault_trapno(int sig, int code, void __user *addr, int trapno) in force_sig_fault_trapno() argument
1897 info.si_signo = sig; in force_sig_fault_trapno()
1908 int send_sig_fault_trapno(int sig, int code, void __user *addr, int trapno, in send_sig_fault_trapno() argument
1914 info.si_signo = sig; in send_sig_fault_trapno()
1922 int kill_pgrp(struct pid *pid, int sig, int priv) in kill_pgrp() argument
1927 ret = __kill_pgrp_info(sig, __si_special(priv), pid); in kill_pgrp()
1934 int kill_pid(struct pid *pid, int sig, int priv) in kill_pid() argument
1936 return kill_pid_info(sig, __si_special(priv), pid); in kill_pid()
1981 int sig = q->info.si_signo; in send_sigqueue() local
2014 if (!prepare_signal(sig, t, false)) in send_sigqueue()
2030 signalfd_notify(t, sig); in send_sigqueue()
2033 sigaddset(&pending->signal, sig); in send_sigqueue()
2034 complete_signal(sig, t, type); in send_sigqueue()
2037 trace_signal_generate(sig, &q->info, t, type != PIDTYPE_PID, result); in send_sigqueue()
2060 bool do_notify_parent(struct task_struct *tsk, int sig) in do_notify_parent() argument
2068 WARN_ON_ONCE(sig == -1); in do_notify_parent()
2079 if (sig != SIGCHLD) { in do_notify_parent()
2085 sig = SIGCHLD; in do_notify_parent()
2089 info.si_signo = sig; in do_notify_parent()
2124 if (!tsk->ptrace && sig == SIGCHLD && in do_notify_parent()
2144 sig = 0; in do_notify_parent()
2150 if (valid_signal(sig) && sig) in do_notify_parent()
2151 __send_signal_locked(sig, &info, tsk->parent, PIDTYPE_TGID, false); in do_notify_parent()
2422 struct signal_struct *sig = current->signal; in do_signal_stop() local
2432 unlikely(sig->flags & SIGNAL_GROUP_EXIT) || in do_signal_stop()
2433 unlikely(sig->group_exec_task)) in do_signal_stop()
2454 if (!(sig->flags & SIGNAL_STOP_STOPPED)) in do_signal_stop()
2455 sig->group_exit_code = signr; in do_signal_stop()
2457 sig->group_stop_count = 0; in do_signal_stop()
2460 sig->group_stop_count++; in do_signal_stop()
2471 sig->group_stop_count++; in do_signal_stop()
2650 switch (siginfo_layout(ksig->sig, ksig->info.si_code)) { in hide_si_addr_tag_bits()
2658 ksig->info.si_addr, ksig->sig, ksig->info.si_code); in hide_si_addr_tag_bits()
2907 ksig->sig = signr; in get_signal()
2912 return ksig->sig > 0; in get_signal()
2937 sigaddset(&blocked, ksig->sig); in signal_delivered()
2948 force_sigsegv(ksig->sig); in signal_setup_done()
3305 static bool known_siginfo_layout(unsigned sig, int si_code) in known_siginfo_layout() argument
3310 if (sig_specific_sicodes(sig)) { in known_siginfo_layout()
3311 if (si_code <= sig_sicodes[sig].limit) in known_siginfo_layout()
3324 enum siginfo_layout siginfo_layout(unsigned sig, int si_code) in siginfo_layout() argument
3328 if ((sig < ARRAY_SIZE(sig_sicodes)) && in siginfo_layout()
3329 (si_code <= sig_sicodes[sig].limit)) { in siginfo_layout()
3330 layout = sig_sicodes[sig].layout; in siginfo_layout()
3332 if ((sig == SIGBUS) && in siginfo_layout()
3335 else if ((sig == SIGSEGV) && (si_code == SEGV_BNDERR)) in siginfo_layout()
3338 else if ((sig == SIGSEGV) && (si_code == SEGV_PKUERR)) in siginfo_layout()
3341 else if ((sig == SIGTRAP) && (si_code == TRAP_PERF)) in siginfo_layout()
3344 (sig == SIGILL) && (si_code == ILL_ILLTRP)) in siginfo_layout()
3347 ((sig == SIGFPE) || in siginfo_layout()
3348 ((sig == SIGTRAP) && (si_code == TRAP_UNK)))) in siginfo_layout()
3621 int sig, ret = 0; in do_sigtimedwait() local
3637 sig = dequeue_signal(tsk, &mask, info, &type); in do_sigtimedwait()
3638 if (!sig && timeout) { in do_sigtimedwait()
3656 sig = dequeue_signal(tsk, &mask, info, &type); in do_sigtimedwait()
3660 if (sig) in do_sigtimedwait()
3661 return sig; in do_sigtimedwait()
3802 static inline void prepare_kill_siginfo(int sig, struct kernel_siginfo *info) in prepare_kill_siginfo() argument
3805 info->si_signo = sig; in prepare_kill_siginfo()
3817 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) in SYSCALL_DEFINE2() argument
3821 prepare_kill_siginfo(sig, &info); in SYSCALL_DEFINE2()
3823 return kill_something_info(sig, &info, pid); in SYSCALL_DEFINE2()
3892 SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, in SYSCALL_DEFINE4() argument
3925 if (unlikely(sig != kinfo.si_signo)) in SYSCALL_DEFINE4()
3934 prepare_kill_siginfo(sig, &kinfo); in SYSCALL_DEFINE4()
3937 ret = kill_pid_info(sig, &kinfo, pid); in SYSCALL_DEFINE4()
3945 do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info) in do_send_specific() argument
3953 error = check_kill_permission(sig, info, p); in do_send_specific()
3958 if (!error && sig) { in do_send_specific()
3959 error = do_send_sig_info(sig, info, p, PIDTYPE_PID); in do_send_specific()
3974 static int do_tkill(pid_t tgid, pid_t pid, int sig) in do_tkill() argument
3979 info.si_signo = sig; in do_tkill()
3985 return do_send_specific(tgid, pid, sig, &info); in do_tkill()
3998 SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig) in SYSCALL_DEFINE3() argument
4004 return do_tkill(tgid, pid, sig); in SYSCALL_DEFINE3()
4014 SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig) in SYSCALL_DEFINE2() argument
4020 return do_tkill(0, pid, sig); in SYSCALL_DEFINE2()
4023 static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t *info) in do_rt_sigqueueinfo() argument
4033 return kill_proc_info(sig, info, pid); in do_rt_sigqueueinfo()
4042 SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, in SYSCALL_DEFINE3() argument
4046 int ret = __copy_siginfo_from_user(sig, &info, uinfo); in SYSCALL_DEFINE3()
4049 return do_rt_sigqueueinfo(pid, sig, &info); in SYSCALL_DEFINE3()
4055 int, sig, in COMPAT_SYSCALL_DEFINE3()
4059 int ret = __copy_siginfo_from_user32(sig, &info, uinfo); in COMPAT_SYSCALL_DEFINE3()
4062 return do_rt_sigqueueinfo(pid, sig, &info); in COMPAT_SYSCALL_DEFINE3()
4066 static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, kernel_siginfo_t *info) in do_rt_tgsigqueueinfo() argument
4079 return do_send_specific(tgid, pid, sig, info); in do_rt_tgsigqueueinfo()
4082 SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig, in SYSCALL_DEFINE4() argument
4086 int ret = __copy_siginfo_from_user(sig, &info, uinfo); in SYSCALL_DEFINE4()
4089 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info); in SYSCALL_DEFINE4()
4096 int, sig, in COMPAT_SYSCALL_DEFINE4()
4100 int ret = __copy_siginfo_from_user32(sig, &info, uinfo); in COMPAT_SYSCALL_DEFINE4()
4103 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info); in COMPAT_SYSCALL_DEFINE4()
4110 void kernel_sigaction(int sig, __sighandler_t action) in kernel_sigaction() argument
4113 current->sighand->action[sig - 1].sa.sa_handler = action; in kernel_sigaction()
4118 sigaddset(&mask, sig); in kernel_sigaction()
4133 int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) in do_sigaction() argument
4139 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig))) in do_sigaction()
4142 k = &p->sighand->action[sig-1]; in do_sigaction()
4185 if (sig_handler_ignored(sig_handler(p, sig), sig)) { in do_sigaction()
4187 sigaddset(&mask, sig); in do_sigaction()
4391 return put_user(set.sig[0], set32); in COMPAT_SYSCALL_DEFINE1()
4414 old_set = current->blocked.sig[0]; in SYSCALL_DEFINE3()
4430 new_blocked.sig[0] = new_set; in SYSCALL_DEFINE3()
4456 SYSCALL_DEFINE4(rt_sigaction, int, sig, in SYSCALL_DEFINE4() argument
4471 ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL); in SYSCALL_DEFINE4()
4481 COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig, in COMPAT_SYSCALL_DEFINE4() argument
4510 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); in COMPAT_SYSCALL_DEFINE4()
4528 SYSCALL_DEFINE3(sigaction, int, sig, in SYSCALL_DEFINE3() argument
4549 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); in SYSCALL_DEFINE3()
4556 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) in SYSCALL_DEFINE3()
4564 COMPAT_SYSCALL_DEFINE3(sigaction, int, sig, in COMPAT_SYSCALL_DEFINE3() argument
4589 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); in COMPAT_SYSCALL_DEFINE3()
4598 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) in COMPAT_SYSCALL_DEFINE3()
4613 return current->blocked.sig[0]; in SYSCALL_DEFINE0()
4618 int old = current->blocked.sig[0]; in SYSCALL_DEFINE1()
4632 SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler) in SYSCALL_DEFINE2() argument
4641 ret = do_sigaction(sig, &new_sa, &old_sa); in SYSCALL_DEFINE2()
4839 void kdb_send_sig(struct task_struct *t, int sig) in kdb_send_sig() argument
4861 ret = send_signal_locked(sig, SEND_SIG_PRIV, t, PIDTYPE_PID); in kdb_send_sig()
4865 sig, t->pid); in kdb_send_sig()
4867 kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid); in kdb_send_sig()