diff options
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 94ec0a4dde0f..dba6ae99978a 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2276,24 +2276,17 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) | |||
2276 | return kill_something_info(sig, &info, pid); | 2276 | return kill_something_info(sig, &info, pid); |
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | static int do_tkill(pid_t tgid, pid_t pid, int sig) | 2279 | static int |
2280 | do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info) | ||
2280 | { | 2281 | { |
2281 | int error; | ||
2282 | struct siginfo info; | ||
2283 | struct task_struct *p; | 2282 | struct task_struct *p; |
2284 | unsigned long flags; | 2283 | unsigned long flags; |
2285 | 2284 | int error = -ESRCH; | |
2286 | error = -ESRCH; | ||
2287 | info.si_signo = sig; | ||
2288 | info.si_errno = 0; | ||
2289 | info.si_code = SI_TKILL; | ||
2290 | info.si_pid = task_tgid_vnr(current); | ||
2291 | info.si_uid = current_uid(); | ||
2292 | 2285 | ||
2293 | rcu_read_lock(); | 2286 | rcu_read_lock(); |
2294 | p = find_task_by_vpid(pid); | 2287 | p = find_task_by_vpid(pid); |
2295 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { | 2288 | if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { |
2296 | error = check_kill_permission(sig, &info, p); | 2289 | error = check_kill_permission(sig, info, p); |
2297 | /* | 2290 | /* |
2298 | * The null signal is a permissions and process existence | 2291 | * The null signal is a permissions and process existence |
2299 | * probe. No signal is actually delivered. | 2292 | * probe. No signal is actually delivered. |
@@ -2303,7 +2296,7 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig) | |||
2303 | * signal is private anyway. | 2296 | * signal is private anyway. |
2304 | */ | 2297 | */ |
2305 | if (!error && sig && lock_task_sighand(p, &flags)) { | 2298 | if (!error && sig && lock_task_sighand(p, &flags)) { |
2306 | error = specific_send_sig_info(sig, &info, p); | 2299 | error = specific_send_sig_info(sig, info, p); |
2307 | unlock_task_sighand(p, &flags); | 2300 | unlock_task_sighand(p, &flags); |
2308 | } | 2301 | } |
2309 | } | 2302 | } |
@@ -2312,6 +2305,19 @@ static int do_tkill(pid_t tgid, pid_t pid, int sig) | |||
2312 | return error; | 2305 | return error; |
2313 | } | 2306 | } |
2314 | 2307 | ||
2308 | static int do_tkill(pid_t tgid, pid_t pid, int sig) | ||
2309 | { | ||
2310 | struct siginfo info; | ||
2311 | |||
2312 | info.si_signo = sig; | ||
2313 | info.si_errno = 0; | ||
2314 | info.si_code = SI_TKILL; | ||
2315 | info.si_pid = task_tgid_vnr(current); | ||
2316 | info.si_uid = current_uid(); | ||
2317 | |||
2318 | return do_send_specific(tgid, pid, sig, &info); | ||
2319 | } | ||
2320 | |||
2315 | /** | 2321 | /** |
2316 | * sys_tgkill - send signal to one specific thread | 2322 | * sys_tgkill - send signal to one specific thread |
2317 | * @tgid: the thread group ID of the thread | 2323 | * @tgid: the thread group ID of the thread |
@@ -2361,6 +2367,32 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, | |||
2361 | return kill_proc_info(sig, &info, pid); | 2367 | return kill_proc_info(sig, &info, pid); |
2362 | } | 2368 | } |
2363 | 2369 | ||
2370 | long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) | ||
2371 | { | ||
2372 | /* This is only valid for single tasks */ | ||
2373 | if (pid <= 0 || tgid <= 0) | ||
2374 | return -EINVAL; | ||
2375 | |||
2376 | /* Not even root can pretend to send signals from the kernel. | ||
2377 | Nor can they impersonate a kill(), which adds source info. */ | ||
2378 | if (info->si_code >= 0) | ||
2379 | return -EPERM; | ||
2380 | info->si_signo = sig; | ||
2381 | |||
2382 | return do_send_specific(tgid, pid, sig, info); | ||
2383 | } | ||
2384 | |||
2385 | SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig, | ||
2386 | siginfo_t __user *, uinfo) | ||
2387 | { | ||
2388 | siginfo_t info; | ||
2389 | |||
2390 | if (copy_from_user(&info, uinfo, sizeof(siginfo_t))) | ||
2391 | return -EFAULT; | ||
2392 | |||
2393 | return do_rt_tgsigqueueinfo(tgid, pid, sig, &info); | ||
2394 | } | ||
2395 | |||
2364 | int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) | 2396 | int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) |
2365 | { | 2397 | { |
2366 | struct task_struct *t = current; | 2398 | struct task_struct *t = current; |