signal.c (708b8eae0fd532af73ea8350e6dcc10255ff7376) signal.c (76aac0e9a17742e60d408be1a706e9aaad370891)
1/*
2 * linux/kernel/signal.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * 1997-11-02 Modified for POSIX.1b signals by Richard Henderson
7 *
8 * 2003-06-02 Jim Houston - Concurrent Computer Corp.

--- 553 unchanged lines hidden (view full) ---

562
563/*
564 * Bad permissions for sending the signal
565 */
566static int check_kill_permission(int sig, struct siginfo *info,
567 struct task_struct *t)
568{
569 struct pid *sid;
1/*
2 * linux/kernel/signal.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * 1997-11-02 Modified for POSIX.1b signals by Richard Henderson
7 *
8 * 2003-06-02 Jim Houston - Concurrent Computer Corp.

--- 553 unchanged lines hidden (view full) ---

562
563/*
564 * Bad permissions for sending the signal
565 */
566static int check_kill_permission(int sig, struct siginfo *info,
567 struct task_struct *t)
568{
569 struct pid *sid;
570 uid_t uid, euid;
570 int error;
571
572 if (!valid_signal(sig))
573 return -EINVAL;
574
575 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
576 return 0;
577
578 error = audit_signal_info(sig, t); /* Let audit system see the signal */
579 if (error)
580 return error;
581
571 int error;
572
573 if (!valid_signal(sig))
574 return -EINVAL;
575
576 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
577 return 0;
578
579 error = audit_signal_info(sig, t); /* Let audit system see the signal */
580 if (error)
581 return error;
582
582 if ((current->euid ^ t->suid) && (current->euid ^ t->uid) &&
583 (current->uid ^ t->suid) && (current->uid ^ t->uid) &&
583 uid = current_uid();
584 euid = current_euid();
585 if ((euid ^ t->suid) && (euid ^ t->uid) &&
586 (uid ^ t->suid) && (uid ^ t->uid) &&
584 !capable(CAP_KILL)) {
585 switch (sig) {
586 case SIGCONT:
587 sid = task_session(t);
588 /*
589 * We don't return the error if sid == NULL. The
590 * task was unhashed, the caller must notice this.
591 */

--- 247 unchanged lines hidden (view full) ---

839 if (q) {
840 list_add_tail(&q->list, &pending->list);
841 switch ((unsigned long) info) {
842 case (unsigned long) SEND_SIG_NOINFO:
843 q->info.si_signo = sig;
844 q->info.si_errno = 0;
845 q->info.si_code = SI_USER;
846 q->info.si_pid = task_pid_vnr(current);
587 !capable(CAP_KILL)) {
588 switch (sig) {
589 case SIGCONT:
590 sid = task_session(t);
591 /*
592 * We don't return the error if sid == NULL. The
593 * task was unhashed, the caller must notice this.
594 */

--- 247 unchanged lines hidden (view full) ---

842 if (q) {
843 list_add_tail(&q->list, &pending->list);
844 switch ((unsigned long) info) {
845 case (unsigned long) SEND_SIG_NOINFO:
846 q->info.si_signo = sig;
847 q->info.si_errno = 0;
848 q->info.si_code = SI_USER;
849 q->info.si_pid = task_pid_vnr(current);
847 q->info.si_uid = current->uid;
850 q->info.si_uid = current_uid();
848 break;
849 case (unsigned long) SEND_SIG_PRIV:
850 q->info.si_signo = sig;
851 q->info.si_errno = 0;
852 q->info.si_code = SI_KERNEL;
853 q->info.si_pid = 0;
854 q->info.si_uid = 0;
855 break;

--- 737 unchanged lines hidden (view full) ---

1593 siginfo_t info;
1594
1595 BUG_ON((exit_code & (0x7f | ~0xffff)) != SIGTRAP);
1596
1597 memset(&info, 0, sizeof info);
1598 info.si_signo = SIGTRAP;
1599 info.si_code = exit_code;
1600 info.si_pid = task_pid_vnr(current);
851 break;
852 case (unsigned long) SEND_SIG_PRIV:
853 q->info.si_signo = sig;
854 q->info.si_errno = 0;
855 q->info.si_code = SI_KERNEL;
856 q->info.si_pid = 0;
857 q->info.si_uid = 0;
858 break;

--- 737 unchanged lines hidden (view full) ---

1596 siginfo_t info;
1597
1598 BUG_ON((exit_code & (0x7f | ~0xffff)) != SIGTRAP);
1599
1600 memset(&info, 0, sizeof info);
1601 info.si_signo = SIGTRAP;
1602 info.si_code = exit_code;
1603 info.si_pid = task_pid_vnr(current);
1601 info.si_uid = current->uid;
1604 info.si_uid = current_uid();
1602
1603 /* Let the debugger run. */
1604 spin_lock_irq(&current->sighand->siglock);
1605 ptrace_stop(exit_code, 1, &info);
1606 spin_unlock_irq(&current->sighand->siglock);
1607}
1608
1609static void

--- 596 unchanged lines hidden (view full) ---

2206sys_kill(pid_t pid, int sig)
2207{
2208 struct siginfo info;
2209
2210 info.si_signo = sig;
2211 info.si_errno = 0;
2212 info.si_code = SI_USER;
2213 info.si_pid = task_tgid_vnr(current);
1605
1606 /* Let the debugger run. */
1607 spin_lock_irq(&current->sighand->siglock);
1608 ptrace_stop(exit_code, 1, &info);
1609 spin_unlock_irq(&current->sighand->siglock);
1610}
1611
1612static void

--- 596 unchanged lines hidden (view full) ---

2209sys_kill(pid_t pid, int sig)
2210{
2211 struct siginfo info;
2212
2213 info.si_signo = sig;
2214 info.si_errno = 0;
2215 info.si_code = SI_USER;
2216 info.si_pid = task_tgid_vnr(current);
2214 info.si_uid = current->uid;
2217 info.si_uid = current_uid();
2215
2216 return kill_something_info(sig, &info, pid);
2217}
2218
2219static int do_tkill(pid_t tgid, pid_t pid, int sig)
2220{
2221 int error;
2222 struct siginfo info;
2223 struct task_struct *p;
2224 unsigned long flags;
2225
2226 error = -ESRCH;
2227 info.si_signo = sig;
2228 info.si_errno = 0;
2229 info.si_code = SI_TKILL;
2230 info.si_pid = task_tgid_vnr(current);
2218
2219 return kill_something_info(sig, &info, pid);
2220}
2221
2222static int do_tkill(pid_t tgid, pid_t pid, int sig)
2223{
2224 int error;
2225 struct siginfo info;
2226 struct task_struct *p;
2227 unsigned long flags;
2228
2229 error = -ESRCH;
2230 info.si_signo = sig;
2231 info.si_errno = 0;
2232 info.si_code = SI_TKILL;
2233 info.si_pid = task_tgid_vnr(current);
2231 info.si_uid = current->uid;
2234 info.si_uid = current_uid();
2232
2233 rcu_read_lock();
2234 p = find_task_by_vpid(pid);
2235 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
2236 error = check_kill_permission(sig, &info, p);
2237 /*
2238 * The null signal is a permissions and process existence
2239 * probe. No signal is actually delivered.

--- 364 unchanged lines hidden ---
2235
2236 rcu_read_lock();
2237 p = find_task_by_vpid(pid);
2238 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
2239 error = check_kill_permission(sig, &info, p);
2240 /*
2241 * The null signal is a permissions and process existence
2242 * probe. No signal is actually delivered.

--- 364 unchanged lines hidden ---