diff options
author | Oleg Nesterov <oleg@tv-sign.ru> | 2008-04-30 03:53:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:37 -0400 |
commit | 2e2ba22ea4fd4bb85f0fa37c521066db6775cbef (patch) | |
tree | aada1523affbcbe1301decad43ad0875e1f680c4 /kernel/signal.c | |
parent | 53c30337f2c61aff6eecf2a446e839641172f9bd (diff) |
signals: check_kill_permission: check session under tasklist_lock
This wasn't documented, but as Atsushi Tsuji pointed out
check_kill_permission() needs tasklist_lock for task_session_nr(). I missed
this fact when removed tasklist from the callers.
Change check_kill_permission() to take tasklist_lock for the SIGCONT case.
Re-order security checks so that we take tasklist_lock only if/when it is
actually needed. This is a minimal fix for now, tasklist will be removed
later.
Also change the code to use task_session() instead of task_session_nr().
Also, remove the SIGCONT check from cap_task_kill(), it is bogus (and the
whole function is bogus. Serge, Eric, why it is still alive?).
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Acked-by: Atsushi Tsuji <a-tsuji@bk.jp.nec.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 251cc13720bd..24be82c0aae3 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -533,6 +533,7 @@ static int rm_from_queue(unsigned long mask, struct sigpending *s) | |||
533 | static int check_kill_permission(int sig, struct siginfo *info, | 533 | static int check_kill_permission(int sig, struct siginfo *info, |
534 | struct task_struct *t) | 534 | struct task_struct *t) |
535 | { | 535 | { |
536 | struct pid *sid; | ||
536 | int error; | 537 | int error; |
537 | 538 | ||
538 | if (!valid_signal(sig)) | 539 | if (!valid_signal(sig)) |
@@ -545,11 +546,24 @@ static int check_kill_permission(int sig, struct siginfo *info, | |||
545 | if (error) | 546 | if (error) |
546 | return error; | 547 | return error; |
547 | 548 | ||
548 | if (((sig != SIGCONT) || (task_session_nr(current) != task_session_nr(t))) | 549 | if ((current->euid ^ t->suid) && (current->euid ^ t->uid) && |
549 | && (current->euid ^ t->suid) && (current->euid ^ t->uid) | 550 | (current->uid ^ t->suid) && (current->uid ^ t->uid) && |
550 | && (current->uid ^ t->suid) && (current->uid ^ t->uid) | 551 | !capable(CAP_KILL)) { |
551 | && !capable(CAP_KILL)) | 552 | switch (sig) { |
552 | return -EPERM; | 553 | case SIGCONT: |
554 | read_lock(&tasklist_lock); | ||
555 | sid = task_session(t); | ||
556 | read_unlock(&tasklist_lock); | ||
557 | /* | ||
558 | * We don't return the error if sid == NULL. The | ||
559 | * task was unhashed, the caller must notice this. | ||
560 | */ | ||
561 | if (!sid || sid == task_session(current)) | ||
562 | break; | ||
563 | default: | ||
564 | return -EPERM; | ||
565 | } | ||
566 | } | ||
553 | 567 | ||
554 | return security_task_kill(t, info, sig, 0); | 568 | return security_task_kill(t, info, sig, 0); |
555 | } | 569 | } |