aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c60
1 files changed, 45 insertions, 15 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index d2dd9cf5dcc6..809a228019ad 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -27,7 +27,7 @@
27#include <linux/freezer.h> 27#include <linux/freezer.h>
28#include <linux/pid_namespace.h> 28#include <linux/pid_namespace.h>
29#include <linux/nsproxy.h> 29#include <linux/nsproxy.h>
30#include <trace/sched.h> 30#include <trace/events/sched.h>
31 31
32#include <asm/param.h> 32#include <asm/param.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
@@ -41,8 +41,6 @@
41 41
42static struct kmem_cache *sigqueue_cachep; 42static struct kmem_cache *sigqueue_cachep;
43 43
44DEFINE_TRACE(sched_signal_send);
45
46static void __user *sig_handler(struct task_struct *t, int sig) 44static void __user *sig_handler(struct task_struct *t, int sig)
47{ 45{
48 return t->sighand->action[sig - 1].sa.sa_handler; 46 return t->sighand->action[sig - 1].sa.sa_handler;
@@ -2283,24 +2281,17 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
2283 return kill_something_info(sig, &info, pid); 2281 return kill_something_info(sig, &info, pid);
2284} 2282}
2285 2283
2286static int do_tkill(pid_t tgid, pid_t pid, int sig) 2284static int
2285do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
2287{ 2286{
2288 int error;
2289 struct siginfo info;
2290 struct task_struct *p; 2287 struct task_struct *p;
2291 unsigned long flags; 2288 unsigned long flags;
2292 2289 int error = -ESRCH;
2293 error = -ESRCH;
2294 info.si_signo = sig;
2295 info.si_errno = 0;
2296 info.si_code = SI_TKILL;
2297 info.si_pid = task_tgid_vnr(current);
2298 info.si_uid = current_uid();
2299 2290
2300 rcu_read_lock(); 2291 rcu_read_lock();
2301 p = find_task_by_vpid(pid); 2292 p = find_task_by_vpid(pid);
2302 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { 2293 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
2303 error = check_kill_permission(sig, &info, p); 2294 error = check_kill_permission(sig, info, p);
2304 /* 2295 /*
2305 * The null signal is a permissions and process existence 2296 * The null signal is a permissions and process existence
2306 * probe. No signal is actually delivered. 2297 * probe. No signal is actually delivered.
@@ -2310,7 +2301,7 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig)
2310 * signal is private anyway. 2301 * signal is private anyway.
2311 */ 2302 */
2312 if (!error && sig && lock_task_sighand(p, &flags)) { 2303 if (!error && sig && lock_task_sighand(p, &flags)) {
2313 error = specific_send_sig_info(sig, &info, p); 2304 error = specific_send_sig_info(sig, info, p);
2314 unlock_task_sighand(p, &flags); 2305 unlock_task_sighand(p, &flags);
2315 } 2306 }
2316 } 2307 }
@@ -2319,6 +2310,19 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig)
2319 return error; 2310 return error;
2320} 2311}
2321 2312
2313static int do_tkill(pid_t tgid, pid_t pid, int sig)
2314{
2315 struct siginfo info;
2316
2317 info.si_signo = sig;
2318 info.si_errno = 0;
2319 info.si_code = SI_TKILL;
2320 info.si_pid = task_tgid_vnr(current);
2321 info.si_uid = current_uid();
2322
2323 return do_send_specific(tgid, pid, sig, &info);
2324}
2325
2322/** 2326/**
2323 * sys_tgkill - send signal to one specific thread 2327 * sys_tgkill - send signal to one specific thread
2324 * @tgid: the thread group ID of the thread 2328 * @tgid: the thread group ID of the thread
@@ -2368,6 +2372,32 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig,
2368 return kill_proc_info(sig, &info, pid); 2372 return kill_proc_info(sig, &info, pid);
2369} 2373}
2370 2374
2375long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
2376{
2377 /* This is only valid for single tasks */
2378 if (pid <= 0 || tgid <= 0)
2379 return -EINVAL;
2380
2381 /* Not even root can pretend to send signals from the kernel.
2382 Nor can they impersonate a kill(), which adds source info. */
2383 if (info->si_code >= 0)
2384 return -EPERM;
2385 info->si_signo = sig;
2386
2387 return do_send_specific(tgid, pid, sig, info);
2388}
2389
2390SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig,
2391 siginfo_t __user *, uinfo)
2392{
2393 siginfo_t info;
2394
2395 if (copy_from_user(&info, uinfo, sizeof(siginfo_t)))
2396 return -EFAULT;
2397
2398 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
2399}
2400
2371int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) 2401int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
2372{ 2402{
2373 struct task_struct *t = current; 2403 struct task_struct *t = current;