diff options
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 31751868de88..324eff5468ad 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -636,13 +636,33 @@ static inline bool si_fromuser(const struct siginfo *info) | |||
636 | } | 636 | } |
637 | 637 | ||
638 | /* | 638 | /* |
639 | * called with RCU read lock from check_kill_permission() | ||
640 | */ | ||
641 | static int kill_ok_by_cred(struct task_struct *t) | ||
642 | { | ||
643 | const struct cred *cred = current_cred(); | ||
644 | const struct cred *tcred = __task_cred(t); | ||
645 | |||
646 | if (cred->user->user_ns == tcred->user->user_ns && | ||
647 | (cred->euid == tcred->suid || | ||
648 | cred->euid == tcred->uid || | ||
649 | cred->uid == tcred->suid || | ||
650 | cred->uid == tcred->uid)) | ||
651 | return 1; | ||
652 | |||
653 | if (ns_capable(tcred->user->user_ns, CAP_KILL)) | ||
654 | return 1; | ||
655 | |||
656 | return 0; | ||
657 | } | ||
658 | |||
659 | /* | ||
639 | * Bad permissions for sending the signal | 660 | * Bad permissions for sending the signal |
640 | * - the caller must hold the RCU read lock | 661 | * - the caller must hold the RCU read lock |
641 | */ | 662 | */ |
642 | static int check_kill_permission(int sig, struct siginfo *info, | 663 | static int check_kill_permission(int sig, struct siginfo *info, |
643 | struct task_struct *t) | 664 | struct task_struct *t) |
644 | { | 665 | { |
645 | const struct cred *cred, *tcred; | ||
646 | struct pid *sid; | 666 | struct pid *sid; |
647 | int error; | 667 | int error; |
648 | 668 | ||
@@ -656,14 +676,8 @@ static int check_kill_permission(int sig, struct siginfo *info, | |||
656 | if (error) | 676 | if (error) |
657 | return error; | 677 | return error; |
658 | 678 | ||
659 | cred = current_cred(); | ||
660 | tcred = __task_cred(t); | ||
661 | if (!same_thread_group(current, t) && | 679 | if (!same_thread_group(current, t) && |
662 | (cred->euid ^ tcred->suid) && | 680 | !kill_ok_by_cred(t)) { |
663 | (cred->euid ^ tcred->uid) && | ||
664 | (cred->uid ^ tcred->suid) && | ||
665 | (cred->uid ^ tcred->uid) && | ||
666 | !capable(CAP_KILL)) { | ||
667 | switch (sig) { | 681 | switch (sig) { |
668 | case SIGCONT: | 682 | case SIGCONT: |
669 | sid = task_session(t); | 683 | sid = task_session(t); |