diff options
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 201 |
1 files changed, 145 insertions, 56 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 4e3cff10fdce..7165af5f1b11 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -226,7 +226,7 @@ static inline void print_dropped_signal(int sig) | |||
226 | /* | 226 | /* |
227 | * allocate a new signal queue record | 227 | * allocate a new signal queue record |
228 | * - this may be called without locks if and only if t == current, otherwise an | 228 | * - this may be called without locks if and only if t == current, otherwise an |
229 | * appopriate lock must be held to stop the target task from exiting | 229 | * appropriate lock must be held to stop the target task from exiting |
230 | */ | 230 | */ |
231 | static struct sigqueue * | 231 | static struct sigqueue * |
232 | __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimit) | 232 | __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimit) |
@@ -375,15 +375,15 @@ int unhandled_signal(struct task_struct *tsk, int sig) | |||
375 | return !tracehook_consider_fatal_signal(tsk, sig); | 375 | return !tracehook_consider_fatal_signal(tsk, sig); |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | /* | |
379 | /* Notify the system that a driver wants to block all signals for this | 379 | * Notify the system that a driver wants to block all signals for this |
380 | * process, and wants to be notified if any signals at all were to be | 380 | * process, and wants to be notified if any signals at all were to be |
381 | * sent/acted upon. If the notifier routine returns non-zero, then the | 381 | * sent/acted upon. If the notifier routine returns non-zero, then the |
382 | * signal will be acted upon after all. If the notifier routine returns 0, | 382 | * signal will be acted upon after all. If the notifier routine returns 0, |
383 | * then then signal will be blocked. Only one block per process is | 383 | * then then signal will be blocked. Only one block per process is |
384 | * allowed. priv is a pointer to private data that the notifier routine | 384 | * allowed. priv is a pointer to private data that the notifier routine |
385 | * can use to determine if the signal should be blocked or not. */ | 385 | * can use to determine if the signal should be blocked or not. |
386 | 386 | */ | |
387 | void | 387 | void |
388 | block_all_signals(int (*notifier)(void *priv), void *priv, sigset_t *mask) | 388 | block_all_signals(int (*notifier)(void *priv), void *priv, sigset_t *mask) |
389 | { | 389 | { |
@@ -434,9 +434,10 @@ still_pending: | |||
434 | copy_siginfo(info, &first->info); | 434 | copy_siginfo(info, &first->info); |
435 | __sigqueue_free(first); | 435 | __sigqueue_free(first); |
436 | } else { | 436 | } else { |
437 | /* Ok, it wasn't in the queue. This must be | 437 | /* |
438 | a fast-pathed signal or we must have been | 438 | * Ok, it wasn't in the queue. This must be |
439 | out of queue space. So zero out the info. | 439 | * a fast-pathed signal or we must have been |
440 | * out of queue space. So zero out the info. | ||
440 | */ | 441 | */ |
441 | info->si_signo = sig; | 442 | info->si_signo = sig; |
442 | info->si_errno = 0; | 443 | info->si_errno = 0; |
@@ -468,7 +469,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, | |||
468 | } | 469 | } |
469 | 470 | ||
470 | /* | 471 | /* |
471 | * Dequeue a signal and return the element to the caller, which is | 472 | * Dequeue a signal and return the element to the caller, which is |
472 | * expected to free it. | 473 | * expected to free it. |
473 | * | 474 | * |
474 | * All callers have to hold the siglock. | 475 | * All callers have to hold the siglock. |
@@ -490,7 +491,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) | |||
490 | * itimers are process shared and we restart periodic | 491 | * itimers are process shared and we restart periodic |
491 | * itimers in the signal delivery path to prevent DoS | 492 | * itimers in the signal delivery path to prevent DoS |
492 | * attacks in the high resolution timer case. This is | 493 | * attacks in the high resolution timer case. This is |
493 | * compliant with the old way of self restarting | 494 | * compliant with the old way of self-restarting |
494 | * itimers, as the SIGALRM is a legacy signal and only | 495 | * itimers, as the SIGALRM is a legacy signal and only |
495 | * queued once. Changing the restart behaviour to | 496 | * queued once. Changing the restart behaviour to |
496 | * restart the timer in the signal dequeue path is | 497 | * restart the timer in the signal dequeue path is |
@@ -636,13 +637,33 @@ static inline bool si_fromuser(const struct siginfo *info) | |||
636 | } | 637 | } |
637 | 638 | ||
638 | /* | 639 | /* |
640 | * called with RCU read lock from check_kill_permission() | ||
641 | */ | ||
642 | static int kill_ok_by_cred(struct task_struct *t) | ||
643 | { | ||
644 | const struct cred *cred = current_cred(); | ||
645 | const struct cred *tcred = __task_cred(t); | ||
646 | |||
647 | if (cred->user->user_ns == tcred->user->user_ns && | ||
648 | (cred->euid == tcred->suid || | ||
649 | cred->euid == tcred->uid || | ||
650 | cred->uid == tcred->suid || | ||
651 | cred->uid == tcred->uid)) | ||
652 | return 1; | ||
653 | |||
654 | if (ns_capable(tcred->user->user_ns, CAP_KILL)) | ||
655 | return 1; | ||
656 | |||
657 | return 0; | ||
658 | } | ||
659 | |||
660 | /* | ||
639 | * Bad permissions for sending the signal | 661 | * Bad permissions for sending the signal |
640 | * - the caller must hold the RCU read lock | 662 | * - the caller must hold the RCU read lock |
641 | */ | 663 | */ |
642 | static int check_kill_permission(int sig, struct siginfo *info, | 664 | static int check_kill_permission(int sig, struct siginfo *info, |
643 | struct task_struct *t) | 665 | struct task_struct *t) |
644 | { | 666 | { |
645 | const struct cred *cred, *tcred; | ||
646 | struct pid *sid; | 667 | struct pid *sid; |
647 | int error; | 668 | int error; |
648 | 669 | ||
@@ -656,14 +677,8 @@ static int check_kill_permission(int sig, struct siginfo *info, | |||
656 | if (error) | 677 | if (error) |
657 | return error; | 678 | return error; |
658 | 679 | ||
659 | cred = current_cred(); | ||
660 | tcred = __task_cred(t); | ||
661 | if (!same_thread_group(current, t) && | 680 | if (!same_thread_group(current, t) && |
662 | (cred->euid ^ tcred->suid) && | 681 | !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) { | 682 | switch (sig) { |
668 | case SIGCONT: | 683 | case SIGCONT: |
669 | sid = task_session(t); | 684 | sid = task_session(t); |
@@ -909,14 +924,15 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t, | |||
909 | if (info == SEND_SIG_FORCED) | 924 | if (info == SEND_SIG_FORCED) |
910 | goto out_set; | 925 | goto out_set; |
911 | 926 | ||
912 | /* Real-time signals must be queued if sent by sigqueue, or | 927 | /* |
913 | some other real-time mechanism. It is implementation | 928 | * Real-time signals must be queued if sent by sigqueue, or |
914 | defined whether kill() does so. We attempt to do so, on | 929 | * some other real-time mechanism. It is implementation |
915 | the principle of least surprise, but since kill is not | 930 | * defined whether kill() does so. We attempt to do so, on |
916 | allowed to fail with EAGAIN when low on memory we just | 931 | * the principle of least surprise, but since kill is not |
917 | make sure at least one signal gets delivered and don't | 932 | * allowed to fail with EAGAIN when low on memory we just |
918 | pass on the info struct. */ | 933 | * make sure at least one signal gets delivered and don't |
919 | 934 | * pass on the info struct. | |
935 | */ | ||
920 | if (sig < SIGRTMIN) | 936 | if (sig < SIGRTMIN) |
921 | override_rlimit = (is_si_special(info) || info->si_code >= 0); | 937 | override_rlimit = (is_si_special(info) || info->si_code >= 0); |
922 | else | 938 | else |
@@ -1187,8 +1203,7 @@ retry: | |||
1187 | return error; | 1203 | return error; |
1188 | } | 1204 | } |
1189 | 1205 | ||
1190 | int | 1206 | int kill_proc_info(int sig, struct siginfo *info, pid_t pid) |
1191 | kill_proc_info(int sig, struct siginfo *info, pid_t pid) | ||
1192 | { | 1207 | { |
1193 | int error; | 1208 | int error; |
1194 | rcu_read_lock(); | 1209 | rcu_read_lock(); |
@@ -1285,8 +1300,7 @@ static int kill_something_info(int sig, struct siginfo *info, pid_t pid) | |||
1285 | * These are for backward compatibility with the rest of the kernel source. | 1300 | * These are for backward compatibility with the rest of the kernel source. |
1286 | */ | 1301 | */ |
1287 | 1302 | ||
1288 | int | 1303 | int send_sig_info(int sig, struct siginfo *info, struct task_struct *p) |
1289 | send_sig_info(int sig, struct siginfo *info, struct task_struct *p) | ||
1290 | { | 1304 | { |
1291 | /* | 1305 | /* |
1292 | * Make sure legacy kernel users don't send in bad values | 1306 | * Make sure legacy kernel users don't send in bad values |
@@ -1354,7 +1368,7 @@ EXPORT_SYMBOL(kill_pid); | |||
1354 | * These functions support sending signals using preallocated sigqueue | 1368 | * These functions support sending signals using preallocated sigqueue |
1355 | * structures. This is needed "because realtime applications cannot | 1369 | * structures. This is needed "because realtime applications cannot |
1356 | * afford to lose notifications of asynchronous events, like timer | 1370 | * afford to lose notifications of asynchronous events, like timer |
1357 | * expirations or I/O completions". In the case of Posix Timers | 1371 | * expirations or I/O completions". In the case of POSIX Timers |
1358 | * we allocate the sigqueue structure from the timer_create. If this | 1372 | * we allocate the sigqueue structure from the timer_create. If this |
1359 | * allocation fails we are able to report the failure to the application | 1373 | * allocation fails we are able to report the failure to the application |
1360 | * with an EAGAIN error. | 1374 | * with an EAGAIN error. |
@@ -1539,7 +1553,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, int why) | |||
1539 | info.si_signo = SIGCHLD; | 1553 | info.si_signo = SIGCHLD; |
1540 | info.si_errno = 0; | 1554 | info.si_errno = 0; |
1541 | /* | 1555 | /* |
1542 | * see comment in do_notify_parent() abot the following 3 lines | 1556 | * see comment in do_notify_parent() about the following 4 lines |
1543 | */ | 1557 | */ |
1544 | rcu_read_lock(); | 1558 | rcu_read_lock(); |
1545 | info.si_pid = task_pid_nr_ns(tsk, parent->nsproxy->pid_ns); | 1559 | info.si_pid = task_pid_nr_ns(tsk, parent->nsproxy->pid_ns); |
@@ -1597,7 +1611,7 @@ static inline int may_ptrace_stop(void) | |||
1597 | } | 1611 | } |
1598 | 1612 | ||
1599 | /* | 1613 | /* |
1600 | * Return nonzero if there is a SIGKILL that should be waking us up. | 1614 | * Return non-zero if there is a SIGKILL that should be waking us up. |
1601 | * Called with the siglock held. | 1615 | * Called with the siglock held. |
1602 | */ | 1616 | */ |
1603 | static int sigkill_pending(struct task_struct *tsk) | 1617 | static int sigkill_pending(struct task_struct *tsk) |
@@ -1721,7 +1735,7 @@ void ptrace_notify(int exit_code) | |||
1721 | /* | 1735 | /* |
1722 | * This performs the stopping for SIGSTOP and other stop signals. | 1736 | * This performs the stopping for SIGSTOP and other stop signals. |
1723 | * We have to stop all threads in the thread group. | 1737 | * We have to stop all threads in the thread group. |
1724 | * Returns nonzero if we've actually stopped and released the siglock. | 1738 | * Returns non-zero if we've actually stopped and released the siglock. |
1725 | * Returns zero if we didn't stop and still hold the siglock. | 1739 | * Returns zero if we didn't stop and still hold the siglock. |
1726 | */ | 1740 | */ |
1727 | static int do_signal_stop(int signr) | 1741 | static int do_signal_stop(int signr) |
@@ -1809,10 +1823,12 @@ static int ptrace_signal(int signr, siginfo_t *info, | |||
1809 | 1823 | ||
1810 | current->exit_code = 0; | 1824 | current->exit_code = 0; |
1811 | 1825 | ||
1812 | /* Update the siginfo structure if the signal has | 1826 | /* |
1813 | changed. If the debugger wanted something | 1827 | * Update the siginfo structure if the signal has |
1814 | specific in the siginfo structure then it should | 1828 | * changed. If the debugger wanted something |
1815 | have updated *info via PTRACE_SETSIGINFO. */ | 1829 | * specific in the siginfo structure then it should |
1830 | * have updated *info via PTRACE_SETSIGINFO. | ||
1831 | */ | ||
1816 | if (signr != info->si_signo) { | 1832 | if (signr != info->si_signo) { |
1817 | info->si_signo = signr; | 1833 | info->si_signo = signr; |
1818 | info->si_errno = 0; | 1834 | info->si_errno = 0; |
@@ -1871,7 +1887,7 @@ relock: | |||
1871 | for (;;) { | 1887 | for (;;) { |
1872 | struct k_sigaction *ka; | 1888 | struct k_sigaction *ka; |
1873 | /* | 1889 | /* |
1874 | * Tracing can induce an artifical signal and choose sigaction. | 1890 | * Tracing can induce an artificial signal and choose sigaction. |
1875 | * The return value in @signr determines the default action, | 1891 | * The return value in @signr determines the default action, |
1876 | * but @info->si_signo is the signal number we will report. | 1892 | * but @info->si_signo is the signal number we will report. |
1877 | */ | 1893 | */ |
@@ -2020,7 +2036,8 @@ void exit_signals(struct task_struct *tsk) | |||
2020 | if (!signal_pending(tsk)) | 2036 | if (!signal_pending(tsk)) |
2021 | goto out; | 2037 | goto out; |
2022 | 2038 | ||
2023 | /* It could be that __group_complete_signal() choose us to | 2039 | /* |
2040 | * It could be that __group_complete_signal() choose us to | ||
2024 | * notify about group-wide signal. Another thread should be | 2041 | * notify about group-wide signal. Another thread should be |
2025 | * woken now to take the signal since we will not. | 2042 | * woken now to take the signal since we will not. |
2026 | */ | 2043 | */ |
@@ -2058,6 +2075,9 @@ EXPORT_SYMBOL(unblock_all_signals); | |||
2058 | * System call entry points. | 2075 | * System call entry points. |
2059 | */ | 2076 | */ |
2060 | 2077 | ||
2078 | /** | ||
2079 | * sys_restart_syscall - restart a system call | ||
2080 | */ | ||
2061 | SYSCALL_DEFINE0(restart_syscall) | 2081 | SYSCALL_DEFINE0(restart_syscall) |
2062 | { | 2082 | { |
2063 | struct restart_block *restart = ¤t_thread_info()->restart_block; | 2083 | struct restart_block *restart = ¤t_thread_info()->restart_block; |
@@ -2111,6 +2131,13 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset) | |||
2111 | return error; | 2131 | return error; |
2112 | } | 2132 | } |
2113 | 2133 | ||
2134 | /** | ||
2135 | * sys_rt_sigprocmask - change the list of currently blocked signals | ||
2136 | * @how: whether to add, remove, or set signals | ||
2137 | * @set: stores pending signals | ||
2138 | * @oset: previous value of signal mask if non-null | ||
2139 | * @sigsetsize: size of sigset_t type | ||
2140 | */ | ||
2114 | SYSCALL_DEFINE4(rt_sigprocmask, int, how, sigset_t __user *, set, | 2141 | SYSCALL_DEFINE4(rt_sigprocmask, int, how, sigset_t __user *, set, |
2115 | sigset_t __user *, oset, size_t, sigsetsize) | 2142 | sigset_t __user *, oset, size_t, sigsetsize) |
2116 | { | 2143 | { |
@@ -2169,8 +2196,14 @@ long do_sigpending(void __user *set, unsigned long sigsetsize) | |||
2169 | 2196 | ||
2170 | out: | 2197 | out: |
2171 | return error; | 2198 | return error; |
2172 | } | 2199 | } |
2173 | 2200 | ||
2201 | /** | ||
2202 | * sys_rt_sigpending - examine a pending signal that has been raised | ||
2203 | * while blocked | ||
2204 | * @set: stores pending signals | ||
2205 | * @sigsetsize: size of sigset_t type or larger | ||
2206 | */ | ||
2174 | SYSCALL_DEFINE2(rt_sigpending, sigset_t __user *, set, size_t, sigsetsize) | 2207 | SYSCALL_DEFINE2(rt_sigpending, sigset_t __user *, set, size_t, sigsetsize) |
2175 | { | 2208 | { |
2176 | return do_sigpending(set, sigsetsize); | 2209 | return do_sigpending(set, sigsetsize); |
@@ -2219,9 +2252,9 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) | |||
2219 | err |= __put_user(from->si_trapno, &to->si_trapno); | 2252 | err |= __put_user(from->si_trapno, &to->si_trapno); |
2220 | #endif | 2253 | #endif |
2221 | #ifdef BUS_MCEERR_AO | 2254 | #ifdef BUS_MCEERR_AO |
2222 | /* | 2255 | /* |
2223 | * Other callers might not initialize the si_lsb field, | 2256 | * Other callers might not initialize the si_lsb field, |
2224 | * so check explicitely for the right codes here. | 2257 | * so check explicitly for the right codes here. |
2225 | */ | 2258 | */ |
2226 | if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO) | 2259 | if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO) |
2227 | err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); | 2260 | err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); |
@@ -2250,6 +2283,14 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) | |||
2250 | 2283 | ||
2251 | #endif | 2284 | #endif |
2252 | 2285 | ||
2286 | /** | ||
2287 | * sys_rt_sigtimedwait - synchronously wait for queued signals specified | ||
2288 | * in @uthese | ||
2289 | * @uthese: queued signals to wait for | ||
2290 | * @uinfo: if non-null, the signal's siginfo is returned here | ||
2291 | * @uts: upper bound on process time suspension | ||
2292 | * @sigsetsize: size of sigset_t type | ||
2293 | */ | ||
2253 | SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese, | 2294 | SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese, |
2254 | siginfo_t __user *, uinfo, const struct timespec __user *, uts, | 2295 | siginfo_t __user *, uinfo, const struct timespec __user *, uts, |
2255 | size_t, sigsetsize) | 2296 | size_t, sigsetsize) |
@@ -2266,7 +2307,7 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese, | |||
2266 | 2307 | ||
2267 | if (copy_from_user(&these, uthese, sizeof(these))) | 2308 | if (copy_from_user(&these, uthese, sizeof(these))) |
2268 | return -EFAULT; | 2309 | return -EFAULT; |
2269 | 2310 | ||
2270 | /* | 2311 | /* |
2271 | * Invert the set of allowed signals to get those we | 2312 | * Invert the set of allowed signals to get those we |
2272 | * want to block. | 2313 | * want to block. |
@@ -2291,9 +2332,11 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese, | |||
2291 | + (ts.tv_sec || ts.tv_nsec)); | 2332 | + (ts.tv_sec || ts.tv_nsec)); |
2292 | 2333 | ||
2293 | if (timeout) { | 2334 | if (timeout) { |
2294 | /* None ready -- temporarily unblock those we're | 2335 | /* |
2336 | * None ready -- temporarily unblock those we're | ||
2295 | * interested while we are sleeping in so that we'll | 2337 | * interested while we are sleeping in so that we'll |
2296 | * be awakened when they arrive. */ | 2338 | * be awakened when they arrive. |
2339 | */ | ||
2297 | current->real_blocked = current->blocked; | 2340 | current->real_blocked = current->blocked; |
2298 | sigandsets(¤t->blocked, ¤t->blocked, &these); | 2341 | sigandsets(¤t->blocked, ¤t->blocked, &these); |
2299 | recalc_sigpending(); | 2342 | recalc_sigpending(); |
@@ -2325,6 +2368,11 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese, | |||
2325 | return ret; | 2368 | return ret; |
2326 | } | 2369 | } |
2327 | 2370 | ||
2371 | /** | ||
2372 | * sys_kill - send a signal to a process | ||
2373 | * @pid: the PID of the process | ||
2374 | * @sig: signal to be sent | ||
2375 | */ | ||
2328 | SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) | 2376 | SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) |
2329 | { | 2377 | { |
2330 | struct siginfo info; | 2378 | struct siginfo info; |
@@ -2400,7 +2448,11 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid_t, pid, int, sig) | |||
2400 | return do_tkill(tgid, pid, sig); | 2448 | return do_tkill(tgid, pid, sig); |
2401 | } | 2449 | } |
2402 | 2450 | ||
2403 | /* | 2451 | /** |
2452 | * sys_tkill - send signal to one specific task | ||
2453 | * @pid: the PID of the task | ||
2454 | * @sig: signal to be sent | ||
2455 | * | ||
2404 | * Send a signal to only one task, even if it's a CLONE_THREAD task. | 2456 | * Send a signal to only one task, even if it's a CLONE_THREAD task. |
2405 | */ | 2457 | */ |
2406 | SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig) | 2458 | SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig) |
@@ -2412,6 +2464,12 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig) | |||
2412 | return do_tkill(0, pid, sig); | 2464 | return do_tkill(0, pid, sig); |
2413 | } | 2465 | } |
2414 | 2466 | ||
2467 | /** | ||
2468 | * sys_rt_sigqueueinfo - send signal information to a signal | ||
2469 | * @pid: the PID of the thread | ||
2470 | * @sig: signal to be sent | ||
2471 | * @uinfo: signal info to be sent | ||
2472 | */ | ||
2415 | SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, | 2473 | SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, |
2416 | siginfo_t __user *, uinfo) | 2474 | siginfo_t __user *, uinfo) |
2417 | { | 2475 | { |
@@ -2421,9 +2479,13 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, | |||
2421 | return -EFAULT; | 2479 | return -EFAULT; |
2422 | 2480 | ||
2423 | /* Not even root can pretend to send signals from the kernel. | 2481 | /* Not even root can pretend to send signals from the kernel. |
2424 | Nor can they impersonate a kill(), which adds source info. */ | 2482 | * Nor can they impersonate a kill()/tgkill(), which adds source info. |
2425 | if (info.si_code >= 0) | 2483 | */ |
2484 | if (info.si_code >= 0 || info.si_code == SI_TKILL) { | ||
2485 | /* We used to allow any < 0 si_code */ | ||
2486 | WARN_ON_ONCE(info.si_code < 0); | ||
2426 | return -EPERM; | 2487 | return -EPERM; |
2488 | } | ||
2427 | info.si_signo = sig; | 2489 | info.si_signo = sig; |
2428 | 2490 | ||
2429 | /* POSIX.1b doesn't mention process groups. */ | 2491 | /* POSIX.1b doesn't mention process groups. */ |
@@ -2437,9 +2499,13 @@ long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) | |||
2437 | return -EINVAL; | 2499 | return -EINVAL; |
2438 | 2500 | ||
2439 | /* Not even root can pretend to send signals from the kernel. | 2501 | /* Not even root can pretend to send signals from the kernel. |
2440 | Nor can they impersonate a kill(), which adds source info. */ | 2502 | * Nor can they impersonate a kill()/tgkill(), which adds source info. |
2441 | if (info->si_code >= 0) | 2503 | */ |
2504 | if (info->si_code >= 0 || info->si_code == SI_TKILL) { | ||
2505 | /* We used to allow any < 0 si_code */ | ||
2506 | WARN_ON_ONCE(info->si_code < 0); | ||
2442 | return -EPERM; | 2507 | return -EPERM; |
2508 | } | ||
2443 | info->si_signo = sig; | 2509 | info->si_signo = sig; |
2444 | 2510 | ||
2445 | return do_send_specific(tgid, pid, sig, info); | 2511 | return do_send_specific(tgid, pid, sig, info); |
@@ -2531,12 +2597,11 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s | |||
2531 | 2597 | ||
2532 | error = -EINVAL; | 2598 | error = -EINVAL; |
2533 | /* | 2599 | /* |
2534 | * | 2600 | * Note - this code used to test ss_flags incorrectly: |
2535 | * Note - this code used to test ss_flags incorrectly | ||
2536 | * old code may have been written using ss_flags==0 | 2601 | * old code may have been written using ss_flags==0 |
2537 | * to mean ss_flags==SS_ONSTACK (as this was the only | 2602 | * to mean ss_flags==SS_ONSTACK (as this was the only |
2538 | * way that worked) - this fix preserves that older | 2603 | * way that worked) - this fix preserves that older |
2539 | * mechanism | 2604 | * mechanism. |
2540 | */ | 2605 | */ |
2541 | if (ss_flags != SS_DISABLE && ss_flags != SS_ONSTACK && ss_flags != 0) | 2606 | if (ss_flags != SS_DISABLE && ss_flags != SS_ONSTACK && ss_flags != 0) |
2542 | goto out; | 2607 | goto out; |
@@ -2570,6 +2635,10 @@ out: | |||
2570 | 2635 | ||
2571 | #ifdef __ARCH_WANT_SYS_SIGPENDING | 2636 | #ifdef __ARCH_WANT_SYS_SIGPENDING |
2572 | 2637 | ||
2638 | /** | ||
2639 | * sys_sigpending - examine pending signals | ||
2640 | * @set: where mask of pending signal is returned | ||
2641 | */ | ||
2573 | SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set) | 2642 | SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set) |
2574 | { | 2643 | { |
2575 | return do_sigpending(set, sizeof(*set)); | 2644 | return do_sigpending(set, sizeof(*set)); |
@@ -2578,8 +2647,15 @@ SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set) | |||
2578 | #endif | 2647 | #endif |
2579 | 2648 | ||
2580 | #ifdef __ARCH_WANT_SYS_SIGPROCMASK | 2649 | #ifdef __ARCH_WANT_SYS_SIGPROCMASK |
2581 | /* Some platforms have their own version with special arguments others | 2650 | /** |
2582 | support only sys_rt_sigprocmask. */ | 2651 | * sys_sigprocmask - examine and change blocked signals |
2652 | * @how: whether to add, remove, or set signals | ||
2653 | * @set: signals to add or remove (if non-null) | ||
2654 | * @oset: previous value of signal mask if non-null | ||
2655 | * | ||
2656 | * Some platforms have their own version with special arguments; | ||
2657 | * others support only sys_rt_sigprocmask. | ||
2658 | */ | ||
2583 | 2659 | ||
2584 | SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, set, | 2660 | SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, set, |
2585 | old_sigset_t __user *, oset) | 2661 | old_sigset_t __user *, oset) |
@@ -2632,6 +2708,13 @@ out: | |||
2632 | #endif /* __ARCH_WANT_SYS_SIGPROCMASK */ | 2708 | #endif /* __ARCH_WANT_SYS_SIGPROCMASK */ |
2633 | 2709 | ||
2634 | #ifdef __ARCH_WANT_SYS_RT_SIGACTION | 2710 | #ifdef __ARCH_WANT_SYS_RT_SIGACTION |
2711 | /** | ||
2712 | * sys_rt_sigaction - alter an action taken by a process | ||
2713 | * @sig: signal to be sent | ||
2714 | * @act: new sigaction | ||
2715 | * @oact: used to save the previous sigaction | ||
2716 | * @sigsetsize: size of sigset_t type | ||
2717 | */ | ||
2635 | SYSCALL_DEFINE4(rt_sigaction, int, sig, | 2718 | SYSCALL_DEFINE4(rt_sigaction, int, sig, |
2636 | const struct sigaction __user *, act, | 2719 | const struct sigaction __user *, act, |
2637 | struct sigaction __user *, oact, | 2720 | struct sigaction __user *, oact, |
@@ -2718,6 +2801,12 @@ SYSCALL_DEFINE0(pause) | |||
2718 | #endif | 2801 | #endif |
2719 | 2802 | ||
2720 | #ifdef __ARCH_WANT_SYS_RT_SIGSUSPEND | 2803 | #ifdef __ARCH_WANT_SYS_RT_SIGSUSPEND |
2804 | /** | ||
2805 | * sys_rt_sigsuspend - replace the signal mask for a value with the | ||
2806 | * @unewset value until a signal is received | ||
2807 | * @unewset: new signal mask value | ||
2808 | * @sigsetsize: size of sigset_t type | ||
2809 | */ | ||
2721 | SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize) | 2810 | SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize) |
2722 | { | 2811 | { |
2723 | sigset_t newset; | 2812 | sigset_t newset; |