Commit 621d3121 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

[PATCH] cleanup the usage of SEND_SIG_xxx constants

This patch simplifies some checks for magic siginfo values.  It should not
change the behaviour in any way.
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b67a1b9e
...@@ -1084,6 +1084,11 @@ extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned lon ...@@ -1084,6 +1084,11 @@ extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned lon
#define SEND_SIG_PRIV ((struct siginfo *) 1) #define SEND_SIG_PRIV ((struct siginfo *) 1)
#define SEND_SIG_FORCED ((struct siginfo *) 2) #define SEND_SIG_FORCED ((struct siginfo *) 2)
static inline int is_si_special(const struct siginfo *info)
{
return info <= SEND_SIG_FORCED;
}
/* True if we are on the alternate signal stack. */ /* True if we are on the alternate signal stack. */
static inline int on_sig_stack(unsigned long sp) static inline int on_sig_stack(unsigned long sp)
......
...@@ -651,9 +651,7 @@ static int check_kill_permission(int sig, struct siginfo *info, ...@@ -651,9 +651,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
if (!valid_signal(sig)) if (!valid_signal(sig))
return error; return error;
error = -EPERM; error = -EPERM;
if ((info == SEND_SIG_NOINFO || if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
(info != SEND_SIG_PRIV && info != SEND_SIG_FORCED
&& SI_FROMUSER(info)))
&& ((sig != SIGCONT) || && ((sig != SIGCONT) ||
(current->signal->session != t->signal->session)) (current->signal->session != t->signal->session))
&& (current->euid ^ t->suid) && (current->euid ^ t->uid) && (current->euid ^ t->suid) && (current->euid ^ t->uid)
...@@ -802,7 +800,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, ...@@ -802,7 +800,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
pass on the info struct. */ pass on the info struct. */
q = __sigqueue_alloc(t, GFP_ATOMIC, (sig < SIGRTMIN && q = __sigqueue_alloc(t, GFP_ATOMIC, (sig < SIGRTMIN &&
(info < SEND_SIG_FORCED || (is_si_special(info) ||
info->si_code >= 0))); info->si_code >= 0)));
if (q) { if (q) {
list_add_tail(&q->list, &signals->list); list_add_tail(&q->list, &signals->list);
...@@ -825,16 +823,14 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t, ...@@ -825,16 +823,14 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
copy_siginfo(&q->info, info); copy_siginfo(&q->info, info);
break; break;
} }
} else { } else if (!is_si_special(info)) {
if (sig >= SIGRTMIN if (sig >= SIGRTMIN && info->si_code != SI_USER)
&& info != SEND_SIG_NOINFO && info != SEND_SIG_PRIV
&& info->si_code != SI_USER)
/* /*
* Queue overflow, abort. We may abort if the signal was rt * Queue overflow, abort. We may abort if the signal was rt
* and sent by user using something other than kill(). * and sent by user using something other than kill().
*/ */
return -EAGAIN; return -EAGAIN;
if ((info > SEND_SIG_PRIV) && (info->si_code == SI_TIMER)) if (info->si_code == SI_TIMER)
/* /*
* Set up a return to indicate that we dropped * Set up a return to indicate that we dropped
* the signal. * the signal.
...@@ -860,7 +856,7 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t) ...@@ -860,7 +856,7 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
BUG(); BUG();
assert_spin_locked(&t->sighand->siglock); assert_spin_locked(&t->sighand->siglock);
if ((info > SEND_SIG_FORCED) && (info->si_code == SI_TIMER)) if (!is_si_special(info) && (info->si_code == SI_TIMER))
/* /*
* Set up a return to indicate that we dropped the signal. * Set up a return to indicate that we dropped the signal.
*/ */
...@@ -1052,7 +1048,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p) ...@@ -1052,7 +1048,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
assert_spin_locked(&p->sighand->siglock); assert_spin_locked(&p->sighand->siglock);
handle_stop_signal(sig, p); handle_stop_signal(sig, p);
if ((info > SEND_SIG_FORCED) && (info->si_code == SI_TIMER)) if (!is_si_special(info) && (info->si_code == SI_TIMER))
/* /*
* Set up a return to indicate that we dropped the signal. * Set up a return to indicate that we dropped the signal.
*/ */
......
...@@ -2713,8 +2713,7 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int si ...@@ -2713,8 +2713,7 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info, int si
if (rc) if (rc)
return rc; return rc;
if (info != SEND_SIG_NOINFO && (info == SEND_SIG_PRIV || if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
info == SEND_SIG_FORCED || SI_FROMKERNEL(info)))
return 0; return 0;
if (!sig) if (!sig)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment