#include <linux/slab.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/sched/mm.h>
#include <linux/sched/user.h>
#include <linux/sched/debug.h>
#include <linux/sched/task.h>
#include <linux/sched/task_stack.h>
#include <linux/sched/cputime.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/proc_fs.h>
#include <linux/tty.h>
#include <linux/binfmts.h>
#include <linux/coredump.h>
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/ptrace.h>
#include <linux/signal.h>
#include <linux/signalfd.h>
#include <linux/ratelimit.h>
#include <linux/task_work.h>
#include <linux/capability.h>
#include <linux/freezer.h>
#include <linux/pid_namespace.h>
#include <linux/nsproxy.h>
#include <linux/user_namespace.h>
#include <linux/uprobes.h>
#include <linux/compat.h>
#include <linux/cn_proc.h>
#include <linux/compiler.h>
#include <linux/posix-timers.h>
#include <linux/cgroup.h>
#include <linux/audit.h>
#include <linux/sysctl.h>
#include <uapi/linux/pidfd.h>
#define CREATE_TRACE_POINTS
#include <trace/events/signal.h>
#include <asm/param.h>
#include <linux/uaccess.h>
#include <asm/unistd.h>
#include <asm/siginfo.h>
#include <asm/cacheflush.h>
#include <asm/syscall.h>
static struct kmem_cache *sigqueue_cachep;
int print_fatal_signals __read_mostly;
static void __user *sig_handler(struct task_struct *t, int sig)
{ … }
static inline bool sig_handler_ignored(void __user *handler, int sig)
{ … }
static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
{ … }
static bool sig_ignored(struct task_struct *t, int sig, bool force)
{ … }
static inline bool has_pending_signals(sigset_t *signal, sigset_t *blocked)
{ … }
#define PENDING(p,b) …
static bool recalc_sigpending_tsk(struct task_struct *t)
{ … }
void recalc_sigpending(void)
{ … }
EXPORT_SYMBOL(…);
void calculate_sigpending(void)
{ … }
#define SYNCHRONOUS_MASK …
int next_signal(struct sigpending *pending, sigset_t *mask)
{ … }
static inline void print_dropped_signal(int sig)
{ … }
bool task_set_jobctl_pending(struct task_struct *task, unsigned long mask)
{ … }
void task_clear_jobctl_trapping(struct task_struct *task)
{ … }
void task_clear_jobctl_pending(struct task_struct *task, unsigned long mask)
{ … }
static bool task_participate_group_stop(struct task_struct *task)
{ … }
void task_join_group_stop(struct task_struct *task)
{ … }
static struct sigqueue *
__sigqueue_alloc(int sig, struct task_struct *t, gfp_t gfp_flags,
int override_rlimit, const unsigned int sigqueue_flags)
{ … }
static void __sigqueue_free(struct sigqueue *q)
{ … }
void flush_sigqueue(struct sigpending *queue)
{ … }
void flush_signals(struct task_struct *t)
{ … }
EXPORT_SYMBOL(…);
#ifdef CONFIG_POSIX_TIMERS
static void __flush_itimer_signals(struct sigpending *pending)
{ … }
void flush_itimer_signals(void)
{ … }
#endif
void ignore_signals(struct task_struct *t)
{ … }
void
flush_signal_handlers(struct task_struct *t, int force_default)
{ … }
bool unhandled_signal(struct task_struct *tsk, int sig)
{ … }
static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info,
bool *resched_timer)
{ … }
static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
kernel_siginfo_t *info, bool *resched_timer)
{ … }
int dequeue_signal(struct task_struct *tsk, sigset_t *mask,
kernel_siginfo_t *info, enum pid_type *type)
{ … }
EXPORT_SYMBOL_GPL(…);
static int dequeue_synchronous_signal(kernel_siginfo_t *info)
{ … }
void signal_wake_up_state(struct task_struct *t, unsigned int state)
{ … }
static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
{ … }
static inline int is_si_special(const struct kernel_siginfo *info)
{ … }
static inline bool si_fromuser(const struct kernel_siginfo *info)
{ … }
static bool kill_ok_by_cred(struct task_struct *t)
{ … }
static int check_kill_permission(int sig, struct kernel_siginfo *info,
struct task_struct *t)
{ … }
static void ptrace_trap_notify(struct task_struct *t)
{ … }
static bool prepare_signal(int sig, struct task_struct *p, bool force)
{ … }
static inline bool wants_signal(int sig, struct task_struct *p)
{ … }
static void complete_signal(int sig, struct task_struct *p, enum pid_type type)
{ … }
static inline bool legacy_queue(struct sigpending *signals, int sig)
{ … }
static int __send_signal_locked(int sig, struct kernel_siginfo *info,
struct task_struct *t, enum pid_type type, bool force)
{ … }
static inline bool has_si_pid_and_uid(struct kernel_siginfo *info)
{ … }
int send_signal_locked(int sig, struct kernel_siginfo *info,
struct task_struct *t, enum pid_type type)
{ … }
static void print_fatal_signal(int signr)
{ … }
static int __init setup_print_fatal_signals(char *str)
{ … }
__setup(…);
int do_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p,
enum pid_type type)
{ … }
enum sig_handler { … };
static int
force_sig_info_to_task(struct kernel_siginfo *info, struct task_struct *t,
enum sig_handler handler)
{ … }
int force_sig_info(struct kernel_siginfo *info)
{ … }
int zap_other_threads(struct task_struct *p)
{ … }
struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
unsigned long *flags)
{ … }
#ifdef CONFIG_LOCKDEP
void lockdep_assert_task_sighand_held(struct task_struct *task)
{ … }
#endif
int group_send_sig_info(int sig, struct kernel_siginfo *info,
struct task_struct *p, enum pid_type type)
{ … }
int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp)
{ … }
static int kill_pid_info_type(int sig, struct kernel_siginfo *info,
struct pid *pid, enum pid_type type)
{ … }
int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid)
{ … }
static int kill_proc_info(int sig, struct kernel_siginfo *info, pid_t pid)
{ … }
static inline bool kill_as_cred_perm(const struct cred *cred,
struct task_struct *target)
{ … }
int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr,
struct pid *pid, const struct cred *cred)
{ … }
EXPORT_SYMBOL_GPL(…);
static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid)
{ … }
int send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p)
{ … }
EXPORT_SYMBOL(…);
#define __si_special(priv) …
int
send_sig(int sig, struct task_struct *p, int priv)
{ … }
EXPORT_SYMBOL(…);
void force_sig(int sig)
{ … }
EXPORT_SYMBOL(…);
void force_fatal_sig(int sig)
{ … }
void force_exit_sig(int sig)
{ … }
void force_sigsegv(int sig)
{ … }
int force_sig_fault_to_task(int sig, int code, void __user *addr,
struct task_struct *t)
{ … }
int force_sig_fault(int sig, int code, void __user *addr)
{ … }
int send_sig_fault(int sig, int code, void __user *addr, struct task_struct *t)
{ … }
int force_sig_mceerr(int code, void __user *addr, short lsb)
{ … }
int send_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t)
{ … }
EXPORT_SYMBOL(…);
int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
{ … }
#ifdef SEGV_PKUERR
int force_sig_pkuerr(void __user *addr, u32 pkey)
{ … }
#endif
int send_sig_perf(void __user *addr, u32 type, u64 sig_data)
{ … }
int force_sig_seccomp(int syscall, int reason, bool force_coredump)
{ … }
int force_sig_ptrace_errno_trap(int errno, void __user *addr)
{ … }
int force_sig_fault_trapno(int sig, int code, void __user *addr, int trapno)
{ … }
int send_sig_fault_trapno(int sig, int code, void __user *addr, int trapno,
struct task_struct *t)
{ … }
static int kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp)
{ … }
int kill_pgrp(struct pid *pid, int sig, int priv)
{ … }
EXPORT_SYMBOL(…);
int kill_pid(struct pid *pid, int sig, int priv)
{ … }
EXPORT_SYMBOL(…);
struct sigqueue *sigqueue_alloc(void)
{ … }
void sigqueue_free(struct sigqueue *q)
{ … }
int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
{ … }
void do_notify_pidfd(struct task_struct *task)
{ … }
bool do_notify_parent(struct task_struct *tsk, int sig)
{ … }
static void do_notify_parent_cldstop(struct task_struct *tsk,
bool for_ptracer, int why)
{ … }
static int ptrace_stop(int exit_code, int why, unsigned long message,
kernel_siginfo_t *info)
__releases(¤t->sighand->siglock)
__acquires(¤t->sighand->siglock)
{ … }
static int ptrace_do_notify(int signr, int exit_code, int why, unsigned long message)
{ … }
int ptrace_notify(int exit_code, unsigned long message)
{ … }
static bool do_signal_stop(int signr)
__releases(¤t->sighand->siglock)
{ … }
static void do_jobctl_trap(void)
{ … }
static void do_freezer_trap(void)
__releases(¤t->sighand->siglock)
{ … }
static int ptrace_signal(int signr, kernel_siginfo_t *info, enum pid_type type)
{ … }
static void hide_si_addr_tag_bits(struct ksignal *ksig)
{ … }
bool get_signal(struct ksignal *ksig)
{ … }
static void signal_delivered(struct ksignal *ksig, int stepping)
{ … }
void signal_setup_done(int failed, struct ksignal *ksig, int stepping)
{ … }
static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
{ … }
void exit_signals(struct task_struct *tsk)
{ … }
SYSCALL_DEFINE0(restart_syscall)
{ … }
long do_no_restart_syscall(struct restart_block *param)
{ … }
static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)
{ … }
void set_current_blocked(sigset_t *newset)
{ … }
void __set_current_blocked(const sigset_t *newset)
{ … }
int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
{ … }
EXPORT_SYMBOL(…);
int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize)
{ … }
#ifdef CONFIG_COMPAT
int set_compat_user_sigmask(const compat_sigset_t __user *umask,
size_t sigsetsize)
{ … }
#endif
SYSCALL_DEFINE4(rt_sigprocmask, int, how, sigset_t __user *, nset,
sigset_t __user *, oset, size_t, sigsetsize)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset,
compat_sigset_t __user *, oset, compat_size_t, sigsetsize)
{ … }
#endif
static void do_sigpending(sigset_t *set)
{ … }
SYSCALL_DEFINE2(rt_sigpending, sigset_t __user *, uset, size_t, sigsetsize)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, uset,
compat_size_t, sigsetsize)
{ … }
#endif
static const struct { … } sig_sicodes[] = …;
static bool known_siginfo_layout(unsigned sig, int si_code)
{ … }
enum siginfo_layout siginfo_layout(unsigned sig, int si_code)
{ … }
static inline char __user *si_expansion(const siginfo_t __user *info)
{ … }
int copy_siginfo_to_user(siginfo_t __user *to, const kernel_siginfo_t *from)
{ … }
static int post_copy_siginfo_from_user(kernel_siginfo_t *info,
const siginfo_t __user *from)
{ … }
static int __copy_siginfo_from_user(int signo, kernel_siginfo_t *to,
const siginfo_t __user *from)
{ … }
int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from)
{ … }
#ifdef CONFIG_COMPAT
void copy_siginfo_to_external32(struct compat_siginfo *to,
const struct kernel_siginfo *from)
{ … }
int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
const struct kernel_siginfo *from)
{ … }
static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
const struct compat_siginfo *from)
{ … }
static int __copy_siginfo_from_user32(int signo, struct kernel_siginfo *to,
const struct compat_siginfo __user *ufrom)
{ … }
int copy_siginfo_from_user32(struct kernel_siginfo *to,
const struct compat_siginfo __user *ufrom)
{ … }
#endif
static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
const struct timespec64 *ts)
{ … }
SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese,
siginfo_t __user *, uinfo,
const struct __kernel_timespec __user *, uts,
size_t, sigsetsize)
{ … }
#ifdef CONFIG_COMPAT_32BIT_TIME
SYSCALL_DEFINE4(rt_sigtimedwait_time32, const sigset_t __user *, uthese,
siginfo_t __user *, uinfo,
const struct old_timespec32 __user *, uts,
size_t, sigsetsize)
{ … }
#endif
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait_time64, compat_sigset_t __user *, uthese,
struct compat_siginfo __user *, uinfo,
struct __kernel_timespec __user *, uts, compat_size_t, sigsetsize)
{ … }
#ifdef CONFIG_COMPAT_32BIT_TIME
COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait_time32, compat_sigset_t __user *, uthese,
struct compat_siginfo __user *, uinfo,
struct old_timespec32 __user *, uts, compat_size_t, sigsetsize)
{ … }
#endif
#endif
static void prepare_kill_siginfo(int sig, struct kernel_siginfo *info,
enum pid_type type)
{ … }
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
{ … }
static bool access_pidfd_pidns(struct pid *pid)
{ … }
static int copy_siginfo_from_user_any(kernel_siginfo_t *kinfo,
siginfo_t __user *info)
{ … }
static struct pid *pidfd_to_pid(const struct file *file)
{ … }
#define PIDFD_SEND_SIGNAL_FLAGS …
SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig,
siginfo_t __user *, info, unsigned int, flags)
{ … }
static int
do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info)
{ … }
static int do_tkill(pid_t tgid, pid_t pid, int sig)
{ … }
SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig)
{ … }
SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig)
{ … }
static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t *info)
{ … }
SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig,
siginfo_t __user *, uinfo)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
compat_pid_t, pid,
int, sig,
struct compat_siginfo __user *, uinfo)
{ … }
#endif
static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, kernel_siginfo_t *info)
{ … }
SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig,
siginfo_t __user *, uinfo)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo,
compat_pid_t, tgid,
compat_pid_t, pid,
int, sig,
struct compat_siginfo __user *, uinfo)
{ … }
#endif
void kernel_sigaction(int sig, __sighandler_t action)
{ … }
EXPORT_SYMBOL(…);
void __weak sigaction_compat_abi(struct k_sigaction *act,
struct k_sigaction *oact)
{ … }
int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
{ … }
#ifdef CONFIG_DYNAMIC_SIGFRAME
static inline void sigaltstack_lock(void)
__acquires(¤t->sighand->siglock)
{ … }
static inline void sigaltstack_unlock(void)
__releases(¤t->sighand->siglock)
{ … }
#else
static inline void sigaltstack_lock(void) { }
static inline void sigaltstack_unlock(void) { }
#endif
static int
do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp,
size_t min_ss_size)
{ … }
SYSCALL_DEFINE2(sigaltstack,const stack_t __user *,uss, stack_t __user *,uoss)
{ … }
int restore_altstack(const stack_t __user *uss)
{ … }
int __save_altstack(stack_t __user *uss, unsigned long sp)
{ … }
#ifdef CONFIG_COMPAT
static int do_compat_sigaltstack(const compat_stack_t __user *uss_ptr,
compat_stack_t __user *uoss_ptr)
{ … }
COMPAT_SYSCALL_DEFINE2(sigaltstack,
const compat_stack_t __user *, uss_ptr,
compat_stack_t __user *, uoss_ptr)
{ … }
int compat_restore_altstack(const compat_stack_t __user *uss)
{ … }
int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
{ … }
#endif
#ifdef __ARCH_WANT_SYS_SIGPENDING
SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, uset)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
{ … }
#endif
#endif
#ifdef __ARCH_WANT_SYS_SIGPROCMASK
SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, nset,
old_sigset_t __user *, oset)
{ … }
#endif
#ifndef CONFIG_ODD_RT_SIGACTION
SYSCALL_DEFINE4(rt_sigaction, int, sig,
const struct sigaction __user *, act,
struct sigaction __user *, oact,
size_t, sigsetsize)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig,
const struct compat_sigaction __user *, act,
struct compat_sigaction __user *, oact,
compat_size_t, sigsetsize)
{ … }
#endif
#endif
#ifdef CONFIG_OLD_SIGACTION
SYSCALL_DEFINE3(sigaction, int, sig,
const struct old_sigaction __user *, act,
struct old_sigaction __user *, oact)
{
struct k_sigaction new_ka, old_ka;
int ret;
if (act) {
old_sigset_t mask;
if (!access_ok(act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(mask, &act->sa_mask))
return -EFAULT;
#ifdef __ARCH_HAS_KA_RESTORER
new_ka.ka_restorer = NULL;
#endif
siginitset(&new_ka.sa.sa_mask, mask);
}
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
if (!ret && oact) {
if (!access_ok(oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
return -EFAULT;
}
return ret;
}
#endif
#ifdef CONFIG_COMPAT_OLD_SIGACTION
COMPAT_SYSCALL_DEFINE3(sigaction, int, sig,
const struct compat_old_sigaction __user *, act,
struct compat_old_sigaction __user *, oact)
{ … }
#endif
#ifdef CONFIG_SGETMASK_SYSCALL
SYSCALL_DEFINE0(…)
{ …
SYSCALL_DEFINE1(ssetmask, int, newmask)
{ … }
#endif
#ifdef __ARCH_WANT_SYS_SIGNAL
SYSCALL_DEFINE2(signal, int, sig, __sighandler_t, handler)
{ … }
#endif
#ifdef __ARCH_WANT_SYS_PAUSE
SYSCALL_DEFINE0(…)
{ …
#endif
static int sigsuspend(sigset_t *set)
{ … }
SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize)
{ … }
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE2(rt_sigsuspend, compat_sigset_t __user *, unewset, compat_size_t, sigsetsize)
{ … }
#endif
#ifdef CONFIG_OLD_SIGSUSPEND
SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
{
sigset_t blocked;
siginitset(&blocked, mask);
return sigsuspend(&blocked);
}
#endif
#ifdef CONFIG_OLD_SIGSUSPEND3
SYSCALL_DEFINE3(sigsuspend, int, unused1, int, unused2, old_sigset_t, mask)
{ … }
#endif
__weak const char *arch_vma_name(struct vm_area_struct *vma)
{ … }
static inline void siginfo_buildtime_checks(void)
{ … }
#if defined(CONFIG_SYSCTL)
static struct ctl_table signal_debug_table[] = …;
static int __init init_signal_sysctls(void)
{ … }
early_initcall(init_signal_sysctls);
#endif
void __init signals_init(void)
{ … }
#ifdef CONFIG_KGDB_KDB
#include <linux/kdb.h>
void kdb_send_sig(struct task_struct *t, int sig)
{ … }
#endif