Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
signal.c File Reference
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/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/tracehook.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 <trace/events/signal.h>
#include <asm/param.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <asm/siginfo.h>
#include <asm/cacheflush.h>
#include "audit.h"

Go to the source code of this file.

Macros

#define CREATE_TRACE_POINTS
 
#define PENDING(p, b)   has_pending_signals(&(p)->signal, (b))
 
#define SYNCHRONOUS_MASK
 
#define __si_special(priv)   ((priv) ? SEND_SIG_PRIV : SEND_SIG_NOINFO)
 

Functions

void recalc_sigpending_and_wake (struct task_struct *t)
 
void recalc_sigpending (void)
 
int next_signal (struct sigpending *pending, sigset_t *mask)
 
bool task_set_jobctl_pending (struct task_struct *task, unsigned int mask)
 
void task_clear_jobctl_trapping (struct task_struct *task)
 
void task_clear_jobctl_pending (struct task_struct *task, unsigned int mask)
 
void flush_sigqueue (struct sigpending *queue)
 
void __flush_signals (struct task_struct *t)
 
void flush_signals (struct task_struct *t)
 
void flush_itimer_signals (void)
 
void ignore_signals (struct task_struct *t)
 
void flush_signal_handlers (struct task_struct *t, int force_default)
 
int unhandled_signal (struct task_struct *tsk, int sig)
 
void block_all_signals (int(*notifier)(void *priv), void *priv, sigset_t *mask)
 
void unblock_all_signals (void)
 
int dequeue_signal (struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
 
void signal_wake_up (struct task_struct *t, int resume)
 
 __setup ("print-fatal-signals=", setup_print_fatal_signals)
 
int __group_send_sig_info (int sig, struct siginfo *info, struct task_struct *p)
 
int do_send_sig_info (int sig, struct siginfo *info, struct task_struct *p, bool group)
 
int force_sig_info (int sig, struct siginfo *info, struct task_struct *t)
 
int zap_other_threads (struct task_struct *p)
 
struct sighand_struct__lock_task_sighand (struct task_struct *tsk, unsigned long *flags)
 
int group_send_sig_info (int sig, struct siginfo *info, struct task_struct *p)
 
int __kill_pgrp_info (int sig, struct siginfo *info, struct pid *pgrp)
 
int kill_pid_info (int sig, struct siginfo *info, struct pid *pid)
 
int kill_proc_info (int sig, struct siginfo *info, pid_t pid)
 
int kill_pid_info_as_cred (int sig, struct siginfo *info, struct pid *pid, const struct cred *cred, u32 secid)
 
 EXPORT_SYMBOL_GPL (kill_pid_info_as_cred)
 
int send_sig_info (int sig, struct siginfo *info, struct task_struct *p)
 
int send_sig (int sig, struct task_struct *p, int priv)
 
void force_sig (int sig, struct task_struct *p)
 
int force_sigsegv (int sig, struct task_struct *p)
 
int kill_pgrp (struct pid *pid, int sig, int priv)
 
 EXPORT_SYMBOL (kill_pgrp)
 
int kill_pid (struct pid *pid, int sig, int priv)
 
 EXPORT_SYMBOL (kill_pid)
 
struct sigqueuesigqueue_alloc (void)
 
void sigqueue_free (struct sigqueue *q)
 
int send_sigqueue (struct sigqueue *q, struct task_struct *t, int group)
 
bool do_notify_parent (struct task_struct *tsk, int sig)
 
void ptrace_notify (int exit_code)
 
int get_signal_to_deliver (siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie)
 
void signal_delivered (int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping)
 
void exit_signals (struct task_struct *tsk)
 
 EXPORT_SYMBOL (recalc_sigpending)
 
 EXPORT_SYMBOL_GPL (dequeue_signal)
 
 EXPORT_SYMBOL (flush_signals)
 
 EXPORT_SYMBOL (force_sig)
 
 EXPORT_SYMBOL (send_sig)
 
 EXPORT_SYMBOL (send_sig_info)
 
 EXPORT_SYMBOL (sigprocmask)
 
 EXPORT_SYMBOL (block_all_signals)
 
 EXPORT_SYMBOL (unblock_all_signals)
 
 SYSCALL_DEFINE0 (restart_syscall)
 
long do_no_restart_syscall (struct restart_block *param)
 
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)
 
 SYSCALL_DEFINE4 (rt_sigprocmask, int, how, sigset_t __user *, nset, sigset_t __user *, oset, size_t, sigsetsize)
 
long do_sigpending (void __user *set, unsigned long sigsetsize)
 
 SYSCALL_DEFINE2 (rt_sigpending, sigset_t __user *, set, size_t, sigsetsize)
 
int copy_siginfo_to_user (siginfo_t __user *to, siginfo_t *from)
 
int do_sigtimedwait (const sigset_t *which, siginfo_t *info, const struct timespec *ts)
 
 SYSCALL_DEFINE4 (rt_sigtimedwait, const sigset_t __user *, uthese, siginfo_t __user *, uinfo, const struct timespec __user *, uts, size_t, sigsetsize)
 
 SYSCALL_DEFINE2 (kill, pid_t, pid, int, sig)
 
 SYSCALL_DEFINE3 (tgkill, pid_t, tgid, pid_t, pid, int, sig)
 
 SYSCALL_DEFINE2 (tkill, pid_t, pid, int, sig)
 
 SYSCALL_DEFINE3 (rt_sigqueueinfo, pid_t, pid, int, sig, siginfo_t __user *, uinfo)
 
long do_rt_tgsigqueueinfo (pid_t tgid, pid_t pid, int sig, siginfo_t *info)
 
 SYSCALL_DEFINE4 (rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig, siginfo_t __user *, uinfo)
 
int do_sigaction (int sig, struct k_sigaction *act, struct k_sigaction *oact)
 
int do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long sp)
 
int sigsuspend (sigset_t *set)
 
 __attribute__ ((weak)) const
 
void __init signals_init (void)
 

Variables

int print_fatal_signals __read_mostly
 

Macro Definition Documentation

#define __si_special (   priv)    ((priv) ? SEND_SIG_PRIV : SEND_SIG_NOINFO)

Definition at line 1486 of file signal.c.

#define CREATE_TRACE_POINTS

Definition at line 34 of file signal.c.

#define PENDING (   p,
  b 
)    has_pending_signals(&(p)->signal, (b))

Definition at line 126 of file signal.c.

#define SYNCHRONOUS_MASK
Value:

Definition at line 163 of file signal.c.

Function Documentation

__attribute__ ( (weak)  ) const

Definition at line 3294 of file signal.c.

void __flush_signals ( struct task_struct t)

Definition at line 414 of file signal.c.

int __group_send_sig_info ( int  sig,
struct siginfo info,
struct task_struct p 
)

Definition at line 1196 of file signal.c.

int __kill_pgrp_info ( int  sig,
struct siginfo info,
struct pid pgrp 
)

Definition at line 1332 of file signal.c.

struct sighand_struct* __lock_task_sighand ( struct task_struct tsk,
unsigned long flags 
)
read

Definition at line 1282 of file signal.c.

void __set_current_blocked ( const sigset_t newset)

Definition at line 2546 of file signal.c.

__setup ( )
void block_all_signals ( int(*)(void *priv notifier,
void priv,
sigset_t mask 
)

Definition at line 513 of file signal.c.

int copy_siginfo_to_user ( siginfo_t __user to,
siginfo_t from 
)

Definition at line 2664 of file signal.c.

int dequeue_signal ( struct task_struct tsk,
sigset_t mask,
siginfo_t info 
)

Definition at line 602 of file signal.c.

long do_no_restart_syscall ( struct restart_block param)

Definition at line 2513 of file signal.c.

bool do_notify_parent ( struct task_struct tsk,
int  sig 
)

Definition at line 1633 of file signal.c.

long do_rt_tgsigqueueinfo ( pid_t  tgid,
pid_t  pid,
int  sig,
siginfo_t info 
)

Definition at line 2966 of file signal.c.

int do_send_sig_info ( int  sig,
struct siginfo info,
struct task_struct p,
bool  group 
)

Definition at line 1207 of file signal.c.

int do_sigaction ( int  sig,
struct k_sigaction act,
struct k_sigaction oact 
)

Definition at line 2996 of file signal.c.

int do_sigaltstack ( const stack_t __user uss,
stack_t __user uoss,
unsigned long  sp 
)

Definition at line 3042 of file signal.c.

long do_sigpending ( void __user set,
unsigned long  sigsetsize 
)

Definition at line 2627 of file signal.c.

int do_sigtimedwait ( const sigset_t which,
siginfo_t info,
const struct timespec ts 
)

do_sigtimedwait - wait for queued signals specified in : queued signals to wait for : if non-null, the signal's siginfo is returned here : upper bound on process time suspension

Definition at line 2749 of file signal.c.

void exit_signals ( struct task_struct tsk)

Definition at line 2439 of file signal.c.

EXPORT_SYMBOL ( kill_pgrp  )
EXPORT_SYMBOL ( kill_pid  )
EXPORT_SYMBOL ( recalc_sigpending  )
EXPORT_SYMBOL ( flush_signals  )
EXPORT_SYMBOL ( force_sig  )
EXPORT_SYMBOL ( send_sig  )
EXPORT_SYMBOL ( send_sig_info  )
EXPORT_SYMBOL ( sigprocmask  )
EXPORT_SYMBOL ( block_all_signals  )
EXPORT_SYMBOL ( unblock_all_signals  )
EXPORT_SYMBOL_GPL ( kill_pid_info_as_cred  )
EXPORT_SYMBOL_GPL ( dequeue_signal  )
void flush_itimer_signals ( void  )

Definition at line 453 of file signal.c.

void flush_signal_handlers ( struct task_struct t,
int  force_default 
)

Definition at line 479 of file signal.c.

void flush_signals ( struct task_struct t)

Definition at line 421 of file signal.c.

void flush_sigqueue ( struct sigpending queue)

Definition at line 399 of file signal.c.

void force_sig ( int  sig,
struct task_struct p 
)

Definition at line 1496 of file signal.c.

int force_sig_info ( int  sig,
struct siginfo info,
struct task_struct t 
)

Definition at line 1233 of file signal.c.

int force_sigsegv ( int  sig,
struct task_struct p 
)

Definition at line 1508 of file signal.c.

int get_signal_to_deliver ( siginfo_t info,
struct k_sigaction return_ka,
struct pt_regs regs,
void cookie 
)

Definition at line 2190 of file signal.c.

int group_send_sig_info ( int  sig,
struct siginfo info,
struct task_struct p 
)

Definition at line 1313 of file signal.c.

void ignore_signals ( struct task_struct t)

Definition at line 464 of file signal.c.

int kill_pgrp ( struct pid pid,
int  sig,
int  priv 
)

Definition at line 1520 of file signal.c.

int kill_pid ( struct pid pid,
int  sig,
int  priv 
)

Definition at line 1532 of file signal.c.

int kill_pid_info ( int  sig,
struct siginfo info,
struct pid pid 
)

Definition at line 1347 of file signal.c.

int kill_pid_info_as_cred ( int  sig,
struct siginfo info,
struct pid pid,
const struct cred cred,
u32  secid 
)

Definition at line 1391 of file signal.c.

int kill_proc_info ( int  sig,
struct siginfo info,
pid_t  pid 
)

Definition at line 1371 of file signal.c.

int next_signal ( struct sigpending pending,
sigset_t mask 
)

Definition at line 167 of file signal.c.

void ptrace_notify ( int  exit_code)

Definition at line 1972 of file signal.c.

void recalc_sigpending ( void  )

Definition at line 154 of file signal.c.

void recalc_sigpending_and_wake ( struct task_struct t)

Definition at line 148 of file signal.c.

int send_sig ( int  sig,
struct task_struct p,
int  priv 
)

Definition at line 1490 of file signal.c.

int send_sig_info ( int  sig,
struct siginfo info,
struct task_struct p 
)

Definition at line 1474 of file signal.c.

int send_sigqueue ( struct sigqueue q,
struct task_struct t,
int  group 
)

Definition at line 1582 of file signal.c.

void set_current_blocked ( sigset_t newset)

set_current_blocked - change current->blocked mask : new mask

It is wrong to change ->blocked directly, this helper should be used to ensure the process can't miss a shared signal we are going to block.

Definition at line 2537 of file signal.c.

void signal_delivered ( int  sig,
siginfo_t info,
struct k_sigaction ka,
struct pt_regs regs,
int  stepping 
)

signal_delivered - : number of signal being delivered : siginfo_t of signal being delivered : sigaction setting that chose the handler : user register state : nonzero if debugger single-step or block-step in use

This function should be called when a signal has succesfully been delivered. It updates the blocked signals accordingly (->sa.sa_mask is always blocked, and the signal itself is blocked unless SA_NODEFER is set in ->sa.sa_flags. Tracing is notified.

Definition at line 2389 of file signal.c.

void signal_wake_up ( struct task_struct t,
int  resume 
)

Definition at line 682 of file signal.c.

void __init signals_init ( void  )

Definition at line 3299 of file signal.c.

int sigprocmask ( int  how,
sigset_t set,
sigset_t oldset 
)

Definition at line 2563 of file signal.c.

struct sigqueue* sigqueue_alloc ( void  )
read

Definition at line 1547 of file signal.c.

void sigqueue_free ( struct sigqueue q)

Definition at line 1557 of file signal.c.

int sigsuspend ( sigset_t set)

Definition at line 3262 of file signal.c.

SYSCALL_DEFINE0 ( restart_syscall  )

sys_restart_syscall - restart a system call

Definition at line 2507 of file signal.c.

SYSCALL_DEFINE2 ( rt_sigpending  ,
sigset_t __user ,
set  ,
size_t  ,
sigsetsize   
)

sys_rt_sigpending - examine a pending signal that has been raised while blocked : stores pending signals : size of sigset_t type or larger

Definition at line 2657 of file signal.c.

SYSCALL_DEFINE2 ( kill  ,
pid_t  ,
pid  ,
int  ,
sig   
)

sys_kill - send a signal to a process : the PID of the process : signal to be sent

Definition at line 2847 of file signal.c.

SYSCALL_DEFINE2 ( tkill  ,
pid_t  ,
pid  ,
int  ,
sig   
)

sys_tkill - send signal to one specific task : the PID of the task : signal to be sent

Send a signal to only one task, even if it's a CLONE_THREAD task.

Definition at line 2929 of file signal.c.

SYSCALL_DEFINE3 ( tgkill  ,
pid_t  ,
tgid  ,
pid_t  ,
pid  ,
int  ,
sig   
)

sys_tgkill - send signal to one specific thread : the thread group ID of the thread : the PID of the thread : signal to be sent

This syscall also checks the and returns -ESRCH even if the PID exists but it's not belonging to the target process anymore. This method solves the problem of threads exiting and PIDs getting reused.

Definition at line 2913 of file signal.c.

SYSCALL_DEFINE3 ( rt_sigqueueinfo  ,
pid_t  ,
pid  ,
int  ,
sig  ,
siginfo_t __user ,
uinfo   
)

sys_rt_sigqueueinfo - send signal information to a signal : the PID of the thread : signal to be sent : signal info to be sent

Definition at line 2944 of file signal.c.

SYSCALL_DEFINE4 ( rt_sigprocmask  ,
int  ,
how  ,
sigset_t __user ,
nset  ,
sigset_t __user ,
oset  ,
size_t  ,
sigsetsize   
)

sys_rt_sigprocmask - change the list of currently blocked signals : whether to add, remove, or set signals : stores pending signals : previous value of signal mask if non-null : size of sigset_t type

Definition at line 2597 of file signal.c.

SYSCALL_DEFINE4 ( rt_sigtimedwait  ,
const sigset_t __user ,
uthese  ,
siginfo_t __user ,
uinfo  ,
const struct timespec __user ,
uts  ,
size_t  ,
sigsetsize   
)

sys_rt_sigtimedwait - synchronously wait for queued signals specified in : queued signals to wait for : if non-null, the signal's siginfo is returned here : upper bound on process time suspension : size of sigset_t type

Definition at line 2811 of file signal.c.

SYSCALL_DEFINE4 ( rt_tgsigqueueinfo  ,
pid_t  ,
tgid  ,
pid_t  ,
pid  ,
int  ,
sig  ,
siginfo_t __user ,
uinfo   
)

Definition at line 2985 of file signal.c.

void task_clear_jobctl_pending ( struct task_struct task,
unsigned int  mask 
)

task_clear_jobctl_pending - clear jobctl pending bits : target task : pending bits to clear

Clear from ->jobctl. must be subset of JOBCTL_PENDING_MASK. If JOBCTL_STOP_PENDING is being cleared, other STOP bits are cleared together.

If clearing of leaves no stop or trap pending, this function calls task_clear_jobctl_trapping().

CONTEXT: Must be called with ->sighand->siglock held.

Definition at line 295 of file signal.c.

void task_clear_jobctl_trapping ( struct task_struct task)

task_clear_jobctl_trapping - clear jobctl trapping bit : target task

If JOBCTL_TRAPPING is set, a ptracer is waiting for us to enter TRACED. Clear it and wake up the ptracer. Note that we don't need any further locking. ->siglock guarantees that ->parent points to the ptracer.

CONTEXT: Must be called with ->sighand->siglock held.

Definition at line 272 of file signal.c.

bool task_set_jobctl_pending ( struct task_struct task,
unsigned int  mask 
)

task_set_jobctl_pending - set jobctl pending bits : target task : pending bits to set

Clear from ->jobctl. must be subset of JOBCTL_PENDING_MASK | JOBCTL_STOP_CONSUME | JOBCTL_STOP_SIGMASK | JOBCTL_TRAPPING. If stop signo is being set, the existing signo is cleared. If is already being killed or exiting, this function becomes noop.

CONTEXT: Must be called with ->sighand->siglock held.

RETURNS: true if is set, false if made noop because was dying.

Definition at line 244 of file signal.c.

void unblock_all_signals ( void  )

Definition at line 527 of file signal.c.

int unhandled_signal ( struct task_struct tsk,
int  sig 
)

Definition at line 492 of file signal.c.

int zap_other_threads ( struct task_struct p)

Definition at line 1261 of file signal.c.

Variable Documentation

int print_fatal_signals __read_mostly

Definition at line 50 of file signal.c.