mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-14 01:37:35 +07:00
signals: consolidate checks for whether or not to ignore a signal
Both sig_ignored() and do_sigaction() check for signr to be explicitly or implicitly ignored. Introduce a helper for them. This patch is aimed to help handling signals by pid namespace's init, and was derived from one of Oleg's patches https://lists.linux-foundation.org/pipermail/containers/2007-December/009308.html so, if he doesn't mind, he should be considered as an author. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Oleg Nesterov <oleg@tv-sign.ru> Cc: Roland McGrath <roland@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
06fffb1267
commit
93585eeaf3
@ -39,11 +39,19 @@
|
|||||||
|
|
||||||
static struct kmem_cache *sigqueue_cachep;
|
static struct kmem_cache *sigqueue_cachep;
|
||||||
|
|
||||||
|
static int __sig_ignored(struct task_struct *t, int sig)
|
||||||
|
{
|
||||||
|
void __user *handler;
|
||||||
|
|
||||||
|
/* Is it explicitly or implicitly ignored? */
|
||||||
|
|
||||||
|
handler = t->sighand->action[sig - 1].sa.sa_handler;
|
||||||
|
return handler == SIG_IGN ||
|
||||||
|
(handler == SIG_DFL && sig_kernel_ignore(sig));
|
||||||
|
}
|
||||||
|
|
||||||
static int sig_ignored(struct task_struct *t, int sig)
|
static int sig_ignored(struct task_struct *t, int sig)
|
||||||
{
|
{
|
||||||
void __user * handler;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tracers always want to know about signals..
|
* Tracers always want to know about signals..
|
||||||
*/
|
*/
|
||||||
@ -58,10 +66,7 @@ static int sig_ignored(struct task_struct *t, int sig)
|
|||||||
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
|
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Is it explicitly or implicitly ignored? */
|
return __sig_ignored(t, sig);
|
||||||
handler = t->sighand->action[sig-1].sa.sa_handler;
|
|
||||||
return handler == SIG_IGN ||
|
|
||||||
(handler == SIG_DFL && sig_kernel_ignore(sig));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2331,13 +2336,14 @@ sys_rt_sigqueueinfo(int pid, int sig, siginfo_t __user *uinfo)
|
|||||||
|
|
||||||
int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
|
int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
|
||||||
{
|
{
|
||||||
|
struct task_struct *t = current;
|
||||||
struct k_sigaction *k;
|
struct k_sigaction *k;
|
||||||
sigset_t mask;
|
sigset_t mask;
|
||||||
|
|
||||||
if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
|
if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
k = ¤t->sighand->action[sig-1];
|
k = &t->sighand->action[sig-1];
|
||||||
|
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
spin_lock_irq(¤t->sighand->siglock);
|
||||||
if (oact)
|
if (oact)
|
||||||
@ -2358,9 +2364,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
|
|||||||
* (for example, SIGCHLD), shall cause the pending signal to
|
* (for example, SIGCHLD), shall cause the pending signal to
|
||||||
* be discarded, whether or not it is blocked"
|
* be discarded, whether or not it is blocked"
|
||||||
*/
|
*/
|
||||||
if (act->sa.sa_handler == SIG_IGN ||
|
if (__sig_ignored(t, sig)) {
|
||||||
(act->sa.sa_handler == SIG_DFL && sig_kernel_ignore(sig))) {
|
|
||||||
struct task_struct *t = current;
|
|
||||||
sigemptyset(&mask);
|
sigemptyset(&mask);
|
||||||
sigaddset(&mask, sig);
|
sigaddset(&mask, sig);
|
||||||
rm_from_queue_full(&mask, &t->signal->shared_pending);
|
rm_from_queue_full(&mask, &t->signal->shared_pending);
|
||||||
|
Loading…
Reference in New Issue
Block a user