diff options
Diffstat (limited to 'kernel/signal.c')
| -rw-r--r-- | kernel/signal.c | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index d8034737db4c..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 | ||
| 42 | static struct kmem_cache *sigqueue_cachep; | 42 | static struct kmem_cache *sigqueue_cachep; |
| 43 | 43 | ||
| 44 | DEFINE_TRACE(sched_signal_send); | ||
| 45 | |||
| 46 | static void __user *sig_handler(struct task_struct *t, int sig) | 44 | static 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; |
| @@ -249,14 +247,19 @@ void flush_sigqueue(struct sigpending *queue) | |||
| 249 | /* | 247 | /* |
| 250 | * Flush all pending signals for a task. | 248 | * Flush all pending signals for a task. |
| 251 | */ | 249 | */ |
| 250 | void __flush_signals(struct task_struct *t) | ||
| 251 | { | ||
| 252 | clear_tsk_thread_flag(t, TIF_SIGPENDING); | ||
| 253 | flush_sigqueue(&t->pending); | ||
| 254 | flush_sigqueue(&t->signal->shared_pending); | ||
| 255 | } | ||
| 256 | |||
| 252 | void flush_signals(struct task_struct *t) | 257 | void flush_signals(struct task_struct *t) |
| 253 | { | 258 | { |
| 254 | unsigned long flags; | 259 | unsigned long flags; |
| 255 | 260 | ||
| 256 | spin_lock_irqsave(&t->sighand->siglock, flags); | 261 | spin_lock_irqsave(&t->sighand->siglock, flags); |
| 257 | clear_tsk_thread_flag(t, TIF_SIGPENDING); | 262 | __flush_signals(t); |
| 258 | flush_sigqueue(&t->pending); | ||
| 259 | flush_sigqueue(&t->signal->shared_pending); | ||
| 260 | spin_unlock_irqrestore(&t->sighand->siglock, flags); | 263 | spin_unlock_irqrestore(&t->sighand->siglock, flags); |
| 261 | } | 264 | } |
| 262 | 265 | ||
| @@ -2278,24 +2281,17 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) | |||
| 2278 | return kill_something_info(sig, &info, pid); | 2281 | return kill_something_info(sig, &info, pid); |
| 2279 | } | 2282 | } |
| 2280 | 2283 | ||
| 2281 | static int do_tkill(pid_t tgid, pid_t pid, int sig) | 2284 | static int |
| 2285 | do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info) | ||
| 2282 | { | 2286 | { |
| 2283 | int error; | ||
| 2284 | struct siginfo info; | ||
| 2285 | struct task_struct *p; | 2287 | struct task_struct *p; |
| 2286 | unsigned long flags; | 2288 | unsigned long flags; |
| 2287 | 2289 | int error = -ESRCH; | |
| 2288 | error = -ESRCH; | ||
| 2289 | info.si_signo = sig; | ||
| 2290 | info.si_errno = 0; | ||
| 2291 | info.si_code = SI_TKILL; | ||
| 2292 | info.si_pid = task_tgid_vnr(current); | ||
| 2293 | info.si_uid = current_uid(); | ||
| 2294 | 2290 | ||
| 2295 | rcu_read_lock(); | 2291 | rcu_read_lock(); |
| 2296 | p = find_task_by_vpid(pid); | 2292 | p = find_task_by_vpid(pid); |
| 2297 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { | 2293 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { |
| 2298 | error = check_kill_permission(sig, &info, p); | 2294 | error = check_kill_permission(sig, info, p); |
| 2299 | /* | 2295 | /* |
| 2300 | * The null signal is a permissions and process existence | 2296 | * The null signal is a permissions and process existence |
| 2301 | * probe. No signal is actually delivered. | 2297 | * probe. No signal is actually delivered. |
| @@ -2305,7 +2301,7 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig) | |||
| 2305 | * signal is private anyway. | 2301 | * signal is private anyway. |
| 2306 | */ | 2302 | */ |
| 2307 | if (!error && sig && lock_task_sighand(p, &flags)) { | 2303 | if (!error && sig && lock_task_sighand(p, &flags)) { |
| 2308 | error = specific_send_sig_info(sig, &info, p); | 2304 | error = specific_send_sig_info(sig, info, p); |
| 2309 | unlock_task_sighand(p, &flags); | 2305 | unlock_task_sighand(p, &flags); |
| 2310 | } | 2306 | } |
| 2311 | } | 2307 | } |
| @@ -2314,6 +2310,19 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig) | |||
| 2314 | return error; | 2310 | return error; |
| 2315 | } | 2311 | } |
| 2316 | 2312 | ||
| 2313 | static 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 | |||
| 2317 | /** | 2326 | /** |
| 2318 | * sys_tgkill - send signal to one specific thread | 2327 | * sys_tgkill - send signal to one specific thread |
| 2319 | * @tgid: the thread group ID of the thread | 2328 | * @tgid: the thread group ID of the thread |
| @@ -2363,6 +2372,32 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, | |||
| 2363 | return kill_proc_info(sig, &info, pid); | 2372 | return kill_proc_info(sig, &info, pid); |
| 2364 | } | 2373 | } |
| 2365 | 2374 | ||
| 2375 | long 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 | |||
| 2390 | SYSCALL_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 | |||
| 2366 | int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) | 2401 | int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) |
| 2367 | { | 2402 | { |
| 2368 | struct task_struct *t = current; | 2403 | struct task_struct *t = current; |
