summaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c421
1 files changed, 272 insertions, 149 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index e4aad0e90882..dbd2e4db24cf 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -78,6 +78,10 @@ static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
78 78
79 handler = sig_handler(t, sig); 79 handler = sig_handler(t, sig);
80 80
81 /* SIGKILL and SIGSTOP may not be sent to the global init */
82 if (unlikely(is_global_init(t) && sig_kernel_only(sig)))
83 return true;
84
81 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && 85 if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
82 handler == SIG_DFL && !(force && sig_kernel_only(sig))) 86 handler == SIG_DFL && !(force && sig_kernel_only(sig)))
83 return true; 87 return true;
@@ -172,6 +176,7 @@ void recalc_sigpending(void)
172 clear_thread_flag(TIF_SIGPENDING); 176 clear_thread_flag(TIF_SIGPENDING);
173 177
174} 178}
179EXPORT_SYMBOL(recalc_sigpending);
175 180
176void calculate_sigpending(void) 181void calculate_sigpending(void)
177{ 182{
@@ -462,6 +467,7 @@ void flush_signals(struct task_struct *t)
462 flush_sigqueue(&t->signal->shared_pending); 467 flush_sigqueue(&t->signal->shared_pending);
463 spin_unlock_irqrestore(&t->sighand->siglock, flags); 468 spin_unlock_irqrestore(&t->sighand->siglock, flags);
464} 469}
470EXPORT_SYMBOL(flush_signals);
465 471
466#ifdef CONFIG_POSIX_TIMERS 472#ifdef CONFIG_POSIX_TIMERS
467static void __flush_itimer_signals(struct sigpending *pending) 473static void __flush_itimer_signals(struct sigpending *pending)
@@ -543,7 +549,7 @@ bool unhandled_signal(struct task_struct *tsk, int sig)
543 return !tsk->ptrace; 549 return !tsk->ptrace;
544} 550}
545 551
546static void collect_signal(int sig, struct sigpending *list, siginfo_t *info, 552static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info,
547 bool *resched_timer) 553 bool *resched_timer)
548{ 554{
549 struct sigqueue *q, *first = NULL; 555 struct sigqueue *q, *first = NULL;
@@ -589,7 +595,7 @@ still_pending:
589} 595}
590 596
591static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, 597static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
592 siginfo_t *info, bool *resched_timer) 598 kernel_siginfo_t *info, bool *resched_timer)
593{ 599{
594 int sig = next_signal(pending, mask); 600 int sig = next_signal(pending, mask);
595 601
@@ -604,7 +610,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
604 * 610 *
605 * All callers have to hold the siglock. 611 * All callers have to hold the siglock.
606 */ 612 */
607int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) 613int dequeue_signal(struct task_struct *tsk, sigset_t *mask, kernel_siginfo_t *info)
608{ 614{
609 bool resched_timer = false; 615 bool resched_timer = false;
610 int signr; 616 int signr;
@@ -680,6 +686,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
680#endif 686#endif
681 return signr; 687 return signr;
682} 688}
689EXPORT_SYMBOL_GPL(dequeue_signal);
683 690
684/* 691/*
685 * Tell a process that it has a new active signal.. 692 * Tell a process that it has a new active signal..
@@ -730,12 +737,12 @@ static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
730 } 737 }
731} 738}
732 739
733static inline int is_si_special(const struct siginfo *info) 740static inline int is_si_special(const struct kernel_siginfo *info)
734{ 741{
735 return info <= SEND_SIG_FORCED; 742 return info <= SEND_SIG_PRIV;
736} 743}
737 744
738static inline bool si_fromuser(const struct siginfo *info) 745static inline bool si_fromuser(const struct kernel_siginfo *info)
739{ 746{
740 return info == SEND_SIG_NOINFO || 747 return info == SEND_SIG_NOINFO ||
741 (!is_si_special(info) && SI_FROMUSER(info)); 748 (!is_si_special(info) && SI_FROMUSER(info));
@@ -760,7 +767,7 @@ static bool kill_ok_by_cred(struct task_struct *t)
760 * Bad permissions for sending the signal 767 * Bad permissions for sending the signal
761 * - the caller must hold the RCU read lock 768 * - the caller must hold the RCU read lock
762 */ 769 */
763static int check_kill_permission(int sig, struct siginfo *info, 770static int check_kill_permission(int sig, struct kernel_siginfo *info,
764 struct task_struct *t) 771 struct task_struct *t)
765{ 772{
766 struct pid *sid; 773 struct pid *sid;
@@ -1003,7 +1010,7 @@ static inline bool legacy_queue(struct sigpending *signals, int sig)
1003} 1010}
1004 1011
1005#ifdef CONFIG_USER_NS 1012#ifdef CONFIG_USER_NS
1006static inline void userns_fixup_signal_uid(struct siginfo *info, struct task_struct *t) 1013static inline void userns_fixup_signal_uid(struct kernel_siginfo *info, struct task_struct *t)
1007{ 1014{
1008 if (current_user_ns() == task_cred_xxx(t, user_ns)) 1015 if (current_user_ns() == task_cred_xxx(t, user_ns))
1009 return; 1016 return;
@@ -1017,13 +1024,13 @@ static inline void userns_fixup_signal_uid(struct siginfo *info, struct task_str
1017 rcu_read_unlock(); 1024 rcu_read_unlock();
1018} 1025}
1019#else 1026#else
1020static inline void userns_fixup_signal_uid(struct siginfo *info, struct task_struct *t) 1027static inline void userns_fixup_signal_uid(struct kernel_siginfo *info, struct task_struct *t)
1021{ 1028{
1022 return; 1029 return;
1023} 1030}
1024#endif 1031#endif
1025 1032
1026static int __send_signal(int sig, struct siginfo *info, struct task_struct *t, 1033static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struct *t,
1027 enum pid_type type, int from_ancestor_ns) 1034 enum pid_type type, int from_ancestor_ns)
1028{ 1035{
1029 struct sigpending *pending; 1036 struct sigpending *pending;
@@ -1035,7 +1042,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1035 1042
1036 result = TRACE_SIGNAL_IGNORED; 1043 result = TRACE_SIGNAL_IGNORED;
1037 if (!prepare_signal(sig, t, 1044 if (!prepare_signal(sig, t,
1038 from_ancestor_ns || (info == SEND_SIG_FORCED))) 1045 from_ancestor_ns || (info == SEND_SIG_PRIV)))
1039 goto ret; 1046 goto ret;
1040 1047
1041 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending; 1048 pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;
@@ -1050,10 +1057,10 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
1050 1057
1051 result = TRACE_SIGNAL_DELIVERED; 1058 result = TRACE_SIGNAL_DELIVERED;
1052 /* 1059 /*
1053 * fast-pathed signals for kernel-internal things like SIGSTOP 1060 * Skip useless siginfo allocation for SIGKILL SIGSTOP,
1054 * or SIGKILL. 1061 * and kernel threads.
1055 */ 1062 */
1056 if (info == SEND_SIG_FORCED) 1063 if (sig_kernel_only(sig) || (t->flags & PF_KTHREAD))
1057 goto out_set; 1064 goto out_set;
1058 1065
1059 /* 1066 /*
@@ -1143,7 +1150,7 @@ ret:
1143 return ret; 1150 return ret;
1144} 1151}
1145 1152
1146static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 1153static int send_signal(int sig, struct kernel_siginfo *info, struct task_struct *t,
1147 enum pid_type type) 1154 enum pid_type type)
1148{ 1155{
1149 int from_ancestor_ns = 0; 1156 int from_ancestor_ns = 0;
@@ -1190,18 +1197,12 @@ static int __init setup_print_fatal_signals(char *str)
1190__setup("print-fatal-signals=", setup_print_fatal_signals); 1197__setup("print-fatal-signals=", setup_print_fatal_signals);
1191 1198
1192int 1199int
1193__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p) 1200__group_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p)
1194{ 1201{
1195 return send_signal(sig, info, p, PIDTYPE_TGID); 1202 return send_signal(sig, info, p, PIDTYPE_TGID);
1196} 1203}
1197 1204
1198static int 1205int do_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p,
1199specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
1200{
1201 return send_signal(sig, info, t, PIDTYPE_PID);
1202}
1203
1204int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
1205 enum pid_type type) 1206 enum pid_type type)
1206{ 1207{
1207 unsigned long flags; 1208 unsigned long flags;
@@ -1227,7 +1228,7 @@ int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
1227 * that is why we also clear SIGNAL_UNKILLABLE. 1228 * that is why we also clear SIGNAL_UNKILLABLE.
1228 */ 1229 */
1229int 1230int
1230force_sig_info(int sig, struct siginfo *info, struct task_struct *t) 1231force_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *t)
1231{ 1232{
1232 unsigned long int flags; 1233 unsigned long int flags;
1233 int ret, blocked, ignored; 1234 int ret, blocked, ignored;
@@ -1250,7 +1251,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
1250 */ 1251 */
1251 if (action->sa.sa_handler == SIG_DFL && !t->ptrace) 1252 if (action->sa.sa_handler == SIG_DFL && !t->ptrace)
1252 t->signal->flags &= ~SIGNAL_UNKILLABLE; 1253 t->signal->flags &= ~SIGNAL_UNKILLABLE;
1253 ret = specific_send_sig_info(sig, info, t); 1254 ret = send_signal(sig, info, t, PIDTYPE_PID);
1254 spin_unlock_irqrestore(&t->sighand->siglock, flags); 1255 spin_unlock_irqrestore(&t->sighand->siglock, flags);
1255 1256
1256 return ret; 1257 return ret;
@@ -1315,8 +1316,8 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
1315/* 1316/*
1316 * send signal info to all the members of a group 1317 * send signal info to all the members of a group
1317 */ 1318 */
1318int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p, 1319int group_send_sig_info(int sig, struct kernel_siginfo *info,
1319 enum pid_type type) 1320 struct task_struct *p, enum pid_type type)
1320{ 1321{
1321 int ret; 1322 int ret;
1322 1323
@@ -1335,7 +1336,7 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
1335 * control characters do (^C, ^Z etc) 1336 * control characters do (^C, ^Z etc)
1336 * - the caller must hold at least a readlock on tasklist_lock 1337 * - the caller must hold at least a readlock on tasklist_lock
1337 */ 1338 */
1338int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp) 1339int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp)
1339{ 1340{
1340 struct task_struct *p = NULL; 1341 struct task_struct *p = NULL;
1341 int retval, success; 1342 int retval, success;
@@ -1350,7 +1351,7 @@ int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp)
1350 return success ? 0 : retval; 1351 return success ? 0 : retval;
1351} 1352}
1352 1353
1353int kill_pid_info(int sig, struct siginfo *info, struct pid *pid) 1354int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid)
1354{ 1355{
1355 int error = -ESRCH; 1356 int error = -ESRCH;
1356 struct task_struct *p; 1357 struct task_struct *p;
@@ -1372,7 +1373,7 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
1372 } 1373 }
1373} 1374}
1374 1375
1375static int kill_proc_info(int sig, struct siginfo *info, pid_t pid) 1376static int kill_proc_info(int sig, struct kernel_siginfo *info, pid_t pid)
1376{ 1377{
1377 int error; 1378 int error;
1378 rcu_read_lock(); 1379 rcu_read_lock();
@@ -1393,7 +1394,7 @@ static inline bool kill_as_cred_perm(const struct cred *cred,
1393} 1394}
1394 1395
1395/* like kill_pid_info(), but doesn't use uid/euid of "current" */ 1396/* like kill_pid_info(), but doesn't use uid/euid of "current" */
1396int kill_pid_info_as_cred(int sig, struct siginfo *info, struct pid *pid, 1397int kill_pid_info_as_cred(int sig, struct kernel_siginfo *info, struct pid *pid,
1397 const struct cred *cred) 1398 const struct cred *cred)
1398{ 1399{
1399 int ret = -EINVAL; 1400 int ret = -EINVAL;
@@ -1437,7 +1438,7 @@ EXPORT_SYMBOL_GPL(kill_pid_info_as_cred);
1437 * is probably wrong. Should make it like BSD or SYSV. 1438 * is probably wrong. Should make it like BSD or SYSV.
1438 */ 1439 */
1439 1440
1440static int kill_something_info(int sig, struct siginfo *info, pid_t pid) 1441static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid)
1441{ 1442{
1442 int ret; 1443 int ret;
1443 1444
@@ -1481,7 +1482,7 @@ static int kill_something_info(int sig, struct siginfo *info, pid_t pid)
1481 * These are for backward compatibility with the rest of the kernel source. 1482 * These are for backward compatibility with the rest of the kernel source.
1482 */ 1483 */
1483 1484
1484int send_sig_info(int sig, struct siginfo *info, struct task_struct *p) 1485int send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p)
1485{ 1486{
1486 /* 1487 /*
1487 * Make sure legacy kernel users don't send in bad values 1488 * Make sure legacy kernel users don't send in bad values
@@ -1492,6 +1493,7 @@ int send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
1492 1493
1493 return do_send_sig_info(sig, info, p, PIDTYPE_PID); 1494 return do_send_sig_info(sig, info, p, PIDTYPE_PID);
1494} 1495}
1496EXPORT_SYMBOL(send_sig_info);
1495 1497
1496#define __si_special(priv) \ 1498#define __si_special(priv) \
1497 ((priv) ? SEND_SIG_PRIV : SEND_SIG_NOINFO) 1499 ((priv) ? SEND_SIG_PRIV : SEND_SIG_NOINFO)
@@ -1501,11 +1503,13 @@ send_sig(int sig, struct task_struct *p, int priv)
1501{ 1503{
1502 return send_sig_info(sig, __si_special(priv), p); 1504 return send_sig_info(sig, __si_special(priv), p);
1503} 1505}
1506EXPORT_SYMBOL(send_sig);
1504 1507
1505void force_sig(int sig, struct task_struct *p) 1508void force_sig(int sig, struct task_struct *p)
1506{ 1509{
1507 force_sig_info(sig, SEND_SIG_PRIV, p); 1510 force_sig_info(sig, SEND_SIG_PRIV, p);
1508} 1511}
1512EXPORT_SYMBOL(force_sig);
1509 1513
1510/* 1514/*
1511 * When things go south during signal handling, we 1515 * When things go south during signal handling, we
@@ -1529,7 +1533,7 @@ int force_sig_fault(int sig, int code, void __user *addr
1529 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) 1533 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
1530 , struct task_struct *t) 1534 , struct task_struct *t)
1531{ 1535{
1532 struct siginfo info; 1536 struct kernel_siginfo info;
1533 1537
1534 clear_siginfo(&info); 1538 clear_siginfo(&info);
1535 info.si_signo = sig; 1539 info.si_signo = sig;
@@ -1552,7 +1556,7 @@ int send_sig_fault(int sig, int code, void __user *addr
1552 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) 1556 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
1553 , struct task_struct *t) 1557 , struct task_struct *t)
1554{ 1558{
1555 struct siginfo info; 1559 struct kernel_siginfo info;
1556 1560
1557 clear_siginfo(&info); 1561 clear_siginfo(&info);
1558 info.si_signo = sig; 1562 info.si_signo = sig;
@@ -1572,7 +1576,7 @@ int send_sig_fault(int sig, int code, void __user *addr
1572 1576
1573int force_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t) 1577int force_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t)
1574{ 1578{
1575 struct siginfo info; 1579 struct kernel_siginfo info;
1576 1580
1577 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR)); 1581 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
1578 clear_siginfo(&info); 1582 clear_siginfo(&info);
@@ -1586,7 +1590,7 @@ int force_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct
1586 1590
1587int send_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t) 1591int send_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct *t)
1588{ 1592{
1589 struct siginfo info; 1593 struct kernel_siginfo info;
1590 1594
1591 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR)); 1595 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
1592 clear_siginfo(&info); 1596 clear_siginfo(&info);
@@ -1601,7 +1605,7 @@ EXPORT_SYMBOL(send_sig_mceerr);
1601 1605
1602int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper) 1606int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
1603{ 1607{
1604 struct siginfo info; 1608 struct kernel_siginfo info;
1605 1609
1606 clear_siginfo(&info); 1610 clear_siginfo(&info);
1607 info.si_signo = SIGSEGV; 1611 info.si_signo = SIGSEGV;
@@ -1616,7 +1620,7 @@ int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
1616#ifdef SEGV_PKUERR 1620#ifdef SEGV_PKUERR
1617int force_sig_pkuerr(void __user *addr, u32 pkey) 1621int force_sig_pkuerr(void __user *addr, u32 pkey)
1618{ 1622{
1619 struct siginfo info; 1623 struct kernel_siginfo info;
1620 1624
1621 clear_siginfo(&info); 1625 clear_siginfo(&info);
1622 info.si_signo = SIGSEGV; 1626 info.si_signo = SIGSEGV;
@@ -1633,7 +1637,7 @@ int force_sig_pkuerr(void __user *addr, u32 pkey)
1633 */ 1637 */
1634int force_sig_ptrace_errno_trap(int errno, void __user *addr) 1638int force_sig_ptrace_errno_trap(int errno, void __user *addr)
1635{ 1639{
1636 struct siginfo info; 1640 struct kernel_siginfo info;
1637 1641
1638 clear_siginfo(&info); 1642 clear_siginfo(&info);
1639 info.si_signo = SIGTRAP; 1643 info.si_signo = SIGTRAP;
@@ -1762,7 +1766,7 @@ ret:
1762 */ 1766 */
1763bool do_notify_parent(struct task_struct *tsk, int sig) 1767bool do_notify_parent(struct task_struct *tsk, int sig)
1764{ 1768{
1765 struct siginfo info; 1769 struct kernel_siginfo info;
1766 unsigned long flags; 1770 unsigned long flags;
1767 struct sighand_struct *psig; 1771 struct sighand_struct *psig;
1768 bool autoreap = false; 1772 bool autoreap = false;
@@ -1867,7 +1871,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
1867static void do_notify_parent_cldstop(struct task_struct *tsk, 1871static void do_notify_parent_cldstop(struct task_struct *tsk,
1868 bool for_ptracer, int why) 1872 bool for_ptracer, int why)
1869{ 1873{
1870 struct siginfo info; 1874 struct kernel_siginfo info;
1871 unsigned long flags; 1875 unsigned long flags;
1872 struct task_struct *parent; 1876 struct task_struct *parent;
1873 struct sighand_struct *sighand; 1877 struct sighand_struct *sighand;
@@ -1967,7 +1971,7 @@ static bool sigkill_pending(struct task_struct *tsk)
1967 * If we actually decide not to stop at all because the tracer 1971 * If we actually decide not to stop at all because the tracer
1968 * is gone, we keep current->exit_code unless clear_code. 1972 * is gone, we keep current->exit_code unless clear_code.
1969 */ 1973 */
1970static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info) 1974static void ptrace_stop(int exit_code, int why, int clear_code, kernel_siginfo_t *info)
1971 __releases(&current->sighand->siglock) 1975 __releases(&current->sighand->siglock)
1972 __acquires(&current->sighand->siglock) 1976 __acquires(&current->sighand->siglock)
1973{ 1977{
@@ -2104,7 +2108,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
2104 2108
2105static void ptrace_do_notify(int signr, int exit_code, int why) 2109static void ptrace_do_notify(int signr, int exit_code, int why)
2106{ 2110{
2107 siginfo_t info; 2111 kernel_siginfo_t info;
2108 2112
2109 clear_siginfo(&info); 2113 clear_siginfo(&info);
2110 info.si_signo = signr; 2114 info.si_signo = signr;
@@ -2285,7 +2289,7 @@ static void do_jobctl_trap(void)
2285 } 2289 }
2286} 2290}
2287 2291
2288static int ptrace_signal(int signr, siginfo_t *info) 2292static int ptrace_signal(int signr, kernel_siginfo_t *info)
2289{ 2293{
2290 /* 2294 /*
2291 * We do not check sig_kernel_stop(signr) but set this marker 2295 * We do not check sig_kernel_stop(signr) but set this marker
@@ -2326,7 +2330,7 @@ static int ptrace_signal(int signr, siginfo_t *info)
2326 2330
2327 /* If the (new) signal is now blocked, requeue it. */ 2331 /* If the (new) signal is now blocked, requeue it. */
2328 if (sigismember(&current->blocked, signr)) { 2332 if (sigismember(&current->blocked, signr)) {
2329 specific_send_sig_info(signr, info, current); 2333 send_signal(signr, info, current, PIDTYPE_PID);
2330 signr = 0; 2334 signr = 0;
2331 } 2335 }
2332 2336
@@ -2636,14 +2640,6 @@ out:
2636 } 2640 }
2637} 2641}
2638 2642
2639EXPORT_SYMBOL(recalc_sigpending);
2640EXPORT_SYMBOL_GPL(dequeue_signal);
2641EXPORT_SYMBOL(flush_signals);
2642EXPORT_SYMBOL(force_sig);
2643EXPORT_SYMBOL(send_sig);
2644EXPORT_SYMBOL(send_sig_info);
2645EXPORT_SYMBOL(sigprocmask);
2646
2647/* 2643/*
2648 * System call entry points. 2644 * System call entry points.
2649 */ 2645 */
@@ -2737,6 +2733,7 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
2737 __set_current_blocked(&newset); 2733 __set_current_blocked(&newset);
2738 return 0; 2734 return 0;
2739} 2735}
2736EXPORT_SYMBOL(sigprocmask);
2740 2737
2741/** 2738/**
2742 * sys_rt_sigprocmask - change the list of currently blocked signals 2739 * sys_rt_sigprocmask - change the list of currently blocked signals
@@ -2847,27 +2844,48 @@ COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, uset,
2847} 2844}
2848#endif 2845#endif
2849 2846
2850enum siginfo_layout siginfo_layout(int sig, int si_code) 2847static const struct {
2848 unsigned char limit, layout;
2849} sig_sicodes[] = {
2850 [SIGILL] = { NSIGILL, SIL_FAULT },
2851 [SIGFPE] = { NSIGFPE, SIL_FAULT },
2852 [SIGSEGV] = { NSIGSEGV, SIL_FAULT },
2853 [SIGBUS] = { NSIGBUS, SIL_FAULT },
2854 [SIGTRAP] = { NSIGTRAP, SIL_FAULT },
2855#if defined(SIGEMT)
2856 [SIGEMT] = { NSIGEMT, SIL_FAULT },
2857#endif
2858 [SIGCHLD] = { NSIGCHLD, SIL_CHLD },
2859 [SIGPOLL] = { NSIGPOLL, SIL_POLL },
2860 [SIGSYS] = { NSIGSYS, SIL_SYS },
2861};
2862
2863static bool known_siginfo_layout(unsigned sig, int si_code)
2864{
2865 if (si_code == SI_KERNEL)
2866 return true;
2867 else if ((si_code > SI_USER)) {
2868 if (sig_specific_sicodes(sig)) {
2869 if (si_code <= sig_sicodes[sig].limit)
2870 return true;
2871 }
2872 else if (si_code <= NSIGPOLL)
2873 return true;
2874 }
2875 else if (si_code >= SI_DETHREAD)
2876 return true;
2877 else if (si_code == SI_ASYNCNL)
2878 return true;
2879 return false;
2880}
2881
2882enum siginfo_layout siginfo_layout(unsigned sig, int si_code)
2851{ 2883{
2852 enum siginfo_layout layout = SIL_KILL; 2884 enum siginfo_layout layout = SIL_KILL;
2853 if ((si_code > SI_USER) && (si_code < SI_KERNEL)) { 2885 if ((si_code > SI_USER) && (si_code < SI_KERNEL)) {
2854 static const struct { 2886 if ((sig < ARRAY_SIZE(sig_sicodes)) &&
2855 unsigned char limit, layout; 2887 (si_code <= sig_sicodes[sig].limit)) {
2856 } filter[] = { 2888 layout = sig_sicodes[sig].layout;
2857 [SIGILL] = { NSIGILL, SIL_FAULT },
2858 [SIGFPE] = { NSIGFPE, SIL_FAULT },
2859 [SIGSEGV] = { NSIGSEGV, SIL_FAULT },
2860 [SIGBUS] = { NSIGBUS, SIL_FAULT },
2861 [SIGTRAP] = { NSIGTRAP, SIL_FAULT },
2862#if defined(SIGEMT) && defined(NSIGEMT)
2863 [SIGEMT] = { NSIGEMT, SIL_FAULT },
2864#endif
2865 [SIGCHLD] = { NSIGCHLD, SIL_CHLD },
2866 [SIGPOLL] = { NSIGPOLL, SIL_POLL },
2867 [SIGSYS] = { NSIGSYS, SIL_SYS },
2868 };
2869 if ((sig < ARRAY_SIZE(filter)) && (si_code <= filter[sig].limit)) {
2870 layout = filter[sig].layout;
2871 /* Handle the exceptions */ 2889 /* Handle the exceptions */
2872 if ((sig == SIGBUS) && 2890 if ((sig == SIGBUS) &&
2873 (si_code >= BUS_MCEERR_AR) && (si_code <= BUS_MCEERR_AO)) 2891 (si_code >= BUS_MCEERR_AR) && (si_code <= BUS_MCEERR_AO))
@@ -2892,22 +2910,69 @@ enum siginfo_layout siginfo_layout(int sig, int si_code)
2892 return layout; 2910 return layout;
2893} 2911}
2894 2912
2895int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from) 2913static inline char __user *si_expansion(const siginfo_t __user *info)
2914{
2915 return ((char __user *)info) + sizeof(struct kernel_siginfo);
2916}
2917
2918int copy_siginfo_to_user(siginfo_t __user *to, const kernel_siginfo_t *from)
2896{ 2919{
2897 if (copy_to_user(to, from , sizeof(struct siginfo))) 2920 char __user *expansion = si_expansion(to);
2921 if (copy_to_user(to, from , sizeof(struct kernel_siginfo)))
2922 return -EFAULT;
2923 if (clear_user(expansion, SI_EXPANSION_SIZE))
2898 return -EFAULT; 2924 return -EFAULT;
2899 return 0; 2925 return 0;
2900} 2926}
2901 2927
2928static int post_copy_siginfo_from_user(kernel_siginfo_t *info,
2929 const siginfo_t __user *from)
2930{
2931 if (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) {
2932 char __user *expansion = si_expansion(from);
2933 char buf[SI_EXPANSION_SIZE];
2934 int i;
2935 /*
2936 * An unknown si_code might need more than
2937 * sizeof(struct kernel_siginfo) bytes. Verify all of the
2938 * extra bytes are 0. This guarantees copy_siginfo_to_user
2939 * will return this data to userspace exactly.
2940 */
2941 if (copy_from_user(&buf, expansion, SI_EXPANSION_SIZE))
2942 return -EFAULT;
2943 for (i = 0; i < SI_EXPANSION_SIZE; i++) {
2944 if (buf[i] != 0)
2945 return -E2BIG;
2946 }
2947 }
2948 return 0;
2949}
2950
2951static int __copy_siginfo_from_user(int signo, kernel_siginfo_t *to,
2952 const siginfo_t __user *from)
2953{
2954 if (copy_from_user(to, from, sizeof(struct kernel_siginfo)))
2955 return -EFAULT;
2956 to->si_signo = signo;
2957 return post_copy_siginfo_from_user(to, from);
2958}
2959
2960int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from)
2961{
2962 if (copy_from_user(to, from, sizeof(struct kernel_siginfo)))
2963 return -EFAULT;
2964 return post_copy_siginfo_from_user(to, from);
2965}
2966
2902#ifdef CONFIG_COMPAT 2967#ifdef CONFIG_COMPAT
2903int copy_siginfo_to_user32(struct compat_siginfo __user *to, 2968int copy_siginfo_to_user32(struct compat_siginfo __user *to,
2904 const struct siginfo *from) 2969 const struct kernel_siginfo *from)
2905#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION) 2970#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
2906{ 2971{
2907 return __copy_siginfo_to_user32(to, from, in_x32_syscall()); 2972 return __copy_siginfo_to_user32(to, from, in_x32_syscall());
2908} 2973}
2909int __copy_siginfo_to_user32(struct compat_siginfo __user *to, 2974int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
2910 const struct siginfo *from, bool x32_ABI) 2975 const struct kernel_siginfo *from, bool x32_ABI)
2911#endif 2976#endif
2912{ 2977{
2913 struct compat_siginfo new; 2978 struct compat_siginfo new;
@@ -2991,88 +3056,106 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
2991 return 0; 3056 return 0;
2992} 3057}
2993 3058
2994int copy_siginfo_from_user32(struct siginfo *to, 3059static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
2995 const struct compat_siginfo __user *ufrom) 3060 const struct compat_siginfo *from)
2996{ 3061{
2997 struct compat_siginfo from;
2998
2999 if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
3000 return -EFAULT;
3001
3002 clear_siginfo(to); 3062 clear_siginfo(to);
3003 to->si_signo = from.si_signo; 3063 to->si_signo = from->si_signo;
3004 to->si_errno = from.si_errno; 3064 to->si_errno = from->si_errno;
3005 to->si_code = from.si_code; 3065 to->si_code = from->si_code;
3006 switch(siginfo_layout(from.si_signo, from.si_code)) { 3066 switch(siginfo_layout(from->si_signo, from->si_code)) {
3007 case SIL_KILL: 3067 case SIL_KILL:
3008 to->si_pid = from.si_pid; 3068 to->si_pid = from->si_pid;
3009 to->si_uid = from.si_uid; 3069 to->si_uid = from->si_uid;
3010 break; 3070 break;
3011 case SIL_TIMER: 3071 case SIL_TIMER:
3012 to->si_tid = from.si_tid; 3072 to->si_tid = from->si_tid;
3013 to->si_overrun = from.si_overrun; 3073 to->si_overrun = from->si_overrun;
3014 to->si_int = from.si_int; 3074 to->si_int = from->si_int;
3015 break; 3075 break;
3016 case SIL_POLL: 3076 case SIL_POLL:
3017 to->si_band = from.si_band; 3077 to->si_band = from->si_band;
3018 to->si_fd = from.si_fd; 3078 to->si_fd = from->si_fd;
3019 break; 3079 break;
3020 case SIL_FAULT: 3080 case SIL_FAULT:
3021 to->si_addr = compat_ptr(from.si_addr); 3081 to->si_addr = compat_ptr(from->si_addr);
3022#ifdef __ARCH_SI_TRAPNO 3082#ifdef __ARCH_SI_TRAPNO
3023 to->si_trapno = from.si_trapno; 3083 to->si_trapno = from->si_trapno;
3024#endif 3084#endif
3025 break; 3085 break;
3026 case SIL_FAULT_MCEERR: 3086 case SIL_FAULT_MCEERR:
3027 to->si_addr = compat_ptr(from.si_addr); 3087 to->si_addr = compat_ptr(from->si_addr);
3028#ifdef __ARCH_SI_TRAPNO 3088#ifdef __ARCH_SI_TRAPNO
3029 to->si_trapno = from.si_trapno; 3089 to->si_trapno = from->si_trapno;
3030#endif 3090#endif
3031 to->si_addr_lsb = from.si_addr_lsb; 3091 to->si_addr_lsb = from->si_addr_lsb;
3032 break; 3092 break;
3033 case SIL_FAULT_BNDERR: 3093 case SIL_FAULT_BNDERR:
3034 to->si_addr = compat_ptr(from.si_addr); 3094 to->si_addr = compat_ptr(from->si_addr);
3035#ifdef __ARCH_SI_TRAPNO 3095#ifdef __ARCH_SI_TRAPNO
3036 to->si_trapno = from.si_trapno; 3096 to->si_trapno = from->si_trapno;
3037#endif 3097#endif
3038 to->si_lower = compat_ptr(from.si_lower); 3098 to->si_lower = compat_ptr(from->si_lower);
3039 to->si_upper = compat_ptr(from.si_upper); 3099 to->si_upper = compat_ptr(from->si_upper);
3040 break; 3100 break;
3041 case SIL_FAULT_PKUERR: 3101 case SIL_FAULT_PKUERR:
3042 to->si_addr = compat_ptr(from.si_addr); 3102 to->si_addr = compat_ptr(from->si_addr);
3043#ifdef __ARCH_SI_TRAPNO 3103#ifdef __ARCH_SI_TRAPNO
3044 to->si_trapno = from.si_trapno; 3104 to->si_trapno = from->si_trapno;
3045#endif 3105#endif
3046 to->si_pkey = from.si_pkey; 3106 to->si_pkey = from->si_pkey;
3047 break; 3107 break;
3048 case SIL_CHLD: 3108 case SIL_CHLD:
3049 to->si_pid = from.si_pid; 3109 to->si_pid = from->si_pid;
3050 to->si_uid = from.si_uid; 3110 to->si_uid = from->si_uid;
3051 to->si_status = from.si_status; 3111 to->si_status = from->si_status;
3052#ifdef CONFIG_X86_X32_ABI 3112#ifdef CONFIG_X86_X32_ABI
3053 if (in_x32_syscall()) { 3113 if (in_x32_syscall()) {
3054 to->si_utime = from._sifields._sigchld_x32._utime; 3114 to->si_utime = from->_sifields._sigchld_x32._utime;
3055 to->si_stime = from._sifields._sigchld_x32._stime; 3115 to->si_stime = from->_sifields._sigchld_x32._stime;
3056 } else 3116 } else
3057#endif 3117#endif
3058 { 3118 {
3059 to->si_utime = from.si_utime; 3119 to->si_utime = from->si_utime;
3060 to->si_stime = from.si_stime; 3120 to->si_stime = from->si_stime;
3061 } 3121 }
3062 break; 3122 break;
3063 case SIL_RT: 3123 case SIL_RT:
3064 to->si_pid = from.si_pid; 3124 to->si_pid = from->si_pid;
3065 to->si_uid = from.si_uid; 3125 to->si_uid = from->si_uid;
3066 to->si_int = from.si_int; 3126 to->si_int = from->si_int;
3067 break; 3127 break;
3068 case SIL_SYS: 3128 case SIL_SYS:
3069 to->si_call_addr = compat_ptr(from.si_call_addr); 3129 to->si_call_addr = compat_ptr(from->si_call_addr);
3070 to->si_syscall = from.si_syscall; 3130 to->si_syscall = from->si_syscall;
3071 to->si_arch = from.si_arch; 3131 to->si_arch = from->si_arch;
3072 break; 3132 break;
3073 } 3133 }
3074 return 0; 3134 return 0;
3075} 3135}
3136
3137static int __copy_siginfo_from_user32(int signo, struct kernel_siginfo *to,
3138 const struct compat_siginfo __user *ufrom)
3139{
3140 struct compat_siginfo from;
3141
3142 if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
3143 return -EFAULT;
3144
3145 from.si_signo = signo;
3146 return post_copy_siginfo_from_user32(to, &from);
3147}
3148
3149int copy_siginfo_from_user32(struct kernel_siginfo *to,
3150 const struct compat_siginfo __user *ufrom)
3151{
3152 struct compat_siginfo from;
3153
3154 if (copy_from_user(&from, ufrom, sizeof(struct compat_siginfo)))
3155 return -EFAULT;
3156
3157 return post_copy_siginfo_from_user32(to, &from);
3158}
3076#endif /* CONFIG_COMPAT */ 3159#endif /* CONFIG_COMPAT */
3077 3160
3078/** 3161/**
@@ -3081,7 +3164,7 @@ int copy_siginfo_from_user32(struct siginfo *to,
3081 * @info: if non-null, the signal's siginfo is returned here 3164 * @info: if non-null, the signal's siginfo is returned here
3082 * @ts: upper bound on process time suspension 3165 * @ts: upper bound on process time suspension
3083 */ 3166 */
3084static int do_sigtimedwait(const sigset_t *which, siginfo_t *info, 3167static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
3085 const struct timespec *ts) 3168 const struct timespec *ts)
3086{ 3169{
3087 ktime_t *to = NULL, timeout = KTIME_MAX; 3170 ktime_t *to = NULL, timeout = KTIME_MAX;
@@ -3145,7 +3228,7 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese,
3145{ 3228{
3146 sigset_t these; 3229 sigset_t these;
3147 struct timespec ts; 3230 struct timespec ts;
3148 siginfo_t info; 3231 kernel_siginfo_t info;
3149 int ret; 3232 int ret;
3150 3233
3151 /* XXX: Don't preclude handling different sized sigset_t's. */ 3234 /* XXX: Don't preclude handling different sized sigset_t's. */
@@ -3177,7 +3260,7 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
3177{ 3260{
3178 sigset_t s; 3261 sigset_t s;
3179 struct timespec t; 3262 struct timespec t;
3180 siginfo_t info; 3263 kernel_siginfo_t info;
3181 long ret; 3264 long ret;
3182 3265
3183 if (sigsetsize != sizeof(sigset_t)) 3266 if (sigsetsize != sizeof(sigset_t))
@@ -3209,7 +3292,7 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
3209 */ 3292 */
3210SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) 3293SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
3211{ 3294{
3212 struct siginfo info; 3295 struct kernel_siginfo info;
3213 3296
3214 clear_siginfo(&info); 3297 clear_siginfo(&info);
3215 info.si_signo = sig; 3298 info.si_signo = sig;
@@ -3222,7 +3305,7 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
3222} 3305}
3223 3306
3224static int 3307static int
3225do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info) 3308do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info)
3226{ 3309{
3227 struct task_struct *p; 3310 struct task_struct *p;
3228 int error = -ESRCH; 3311 int error = -ESRCH;
@@ -3253,7 +3336,7 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
3253 3336
3254static int do_tkill(pid_t tgid, pid_t pid, int sig) 3337static int do_tkill(pid_t tgid, pid_t pid, int sig)
3255{ 3338{
3256 struct siginfo info; 3339 struct kernel_siginfo info;
3257 3340
3258 clear_siginfo(&info); 3341 clear_siginfo(&info);
3259 info.si_signo = sig; 3342 info.si_signo = sig;
@@ -3300,7 +3383,7 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig)
3300 return do_tkill(0, pid, sig); 3383 return do_tkill(0, pid, sig);
3301} 3384}
3302 3385
3303static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info) 3386static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t *info)
3304{ 3387{
3305 /* Not even root can pretend to send signals from the kernel. 3388 /* Not even root can pretend to send signals from the kernel.
3306 * Nor can they impersonate a kill()/tgkill(), which adds source info. 3389 * Nor can they impersonate a kill()/tgkill(), which adds source info.
@@ -3309,8 +3392,6 @@ static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info)
3309 (task_pid_vnr(current) != pid)) 3392 (task_pid_vnr(current) != pid))
3310 return -EPERM; 3393 return -EPERM;
3311 3394
3312 info->si_signo = sig;
3313
3314 /* POSIX.1b doesn't mention process groups. */ 3395 /* POSIX.1b doesn't mention process groups. */
3315 return kill_proc_info(sig, info, pid); 3396 return kill_proc_info(sig, info, pid);
3316} 3397}
@@ -3324,9 +3405,10 @@ static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info)
3324SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, 3405SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig,
3325 siginfo_t __user *, uinfo) 3406 siginfo_t __user *, uinfo)
3326{ 3407{
3327 siginfo_t info; 3408 kernel_siginfo_t info;
3328 if (copy_from_user(&info, uinfo, sizeof(siginfo_t))) 3409 int ret = __copy_siginfo_from_user(sig, &info, uinfo);
3329 return -EFAULT; 3410 if (unlikely(ret))
3411 return ret;
3330 return do_rt_sigqueueinfo(pid, sig, &info); 3412 return do_rt_sigqueueinfo(pid, sig, &info);
3331} 3413}
3332 3414
@@ -3336,15 +3418,15 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
3336 int, sig, 3418 int, sig,
3337 struct compat_siginfo __user *, uinfo) 3419 struct compat_siginfo __user *, uinfo)
3338{ 3420{
3339 siginfo_t info; 3421 kernel_siginfo_t info;
3340 int ret = copy_siginfo_from_user32(&info, uinfo); 3422 int ret = __copy_siginfo_from_user32(sig, &info, uinfo);
3341 if (unlikely(ret)) 3423 if (unlikely(ret))
3342 return ret; 3424 return ret;
3343 return do_rt_sigqueueinfo(pid, sig, &info); 3425 return do_rt_sigqueueinfo(pid, sig, &info);
3344} 3426}
3345#endif 3427#endif
3346 3428
3347static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) 3429static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, kernel_siginfo_t *info)
3348{ 3430{
3349 /* This is only valid for single tasks */ 3431 /* This is only valid for single tasks */
3350 if (pid <= 0 || tgid <= 0) 3432 if (pid <= 0 || tgid <= 0)
@@ -3357,19 +3439,16 @@ static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
3357 (task_pid_vnr(current) != pid)) 3439 (task_pid_vnr(current) != pid))
3358 return -EPERM; 3440 return -EPERM;
3359 3441
3360 info->si_signo = sig;
3361
3362 return do_send_specific(tgid, pid, sig, info); 3442 return do_send_specific(tgid, pid, sig, info);
3363} 3443}
3364 3444
3365SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig, 3445SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig,
3366 siginfo_t __user *, uinfo) 3446 siginfo_t __user *, uinfo)
3367{ 3447{
3368 siginfo_t info; 3448 kernel_siginfo_t info;
3369 3449 int ret = __copy_siginfo_from_user(sig, &info, uinfo);
3370 if (copy_from_user(&info, uinfo, sizeof(siginfo_t))) 3450 if (unlikely(ret))
3371 return -EFAULT; 3451 return ret;
3372
3373 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info); 3452 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
3374} 3453}
3375 3454
@@ -3380,10 +3459,10 @@ COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo,
3380 int, sig, 3459 int, sig,
3381 struct compat_siginfo __user *, uinfo) 3460 struct compat_siginfo __user *, uinfo)
3382{ 3461{
3383 siginfo_t info; 3462 kernel_siginfo_t info;
3384 3463 int ret = __copy_siginfo_from_user32(sig, &info, uinfo);
3385 if (copy_siginfo_from_user32(&info, uinfo)) 3464 if (unlikely(ret))
3386 return -EFAULT; 3465 return ret;
3387 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info); 3466 return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
3388} 3467}
3389#endif 3468#endif
@@ -3966,13 +4045,57 @@ __weak const char *arch_vma_name(struct vm_area_struct *vma)
3966 return NULL; 4045 return NULL;
3967} 4046}
3968 4047
3969void __init signals_init(void) 4048static inline void siginfo_buildtime_checks(void)
3970{ 4049{
3971 /* If this check fails, the __ARCH_SI_PREAMBLE_SIZE value is wrong! */
3972 BUILD_BUG_ON(__ARCH_SI_PREAMBLE_SIZE
3973 != offsetof(struct siginfo, _sifields._pad));
3974 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE); 4050 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE);
3975 4051
4052 /* Verify the offsets in the two siginfos match */
4053#define CHECK_OFFSET(field) \
4054 BUILD_BUG_ON(offsetof(siginfo_t, field) != offsetof(kernel_siginfo_t, field))
4055
4056 /* kill */
4057 CHECK_OFFSET(si_pid);
4058 CHECK_OFFSET(si_uid);
4059
4060 /* timer */
4061 CHECK_OFFSET(si_tid);
4062 CHECK_OFFSET(si_overrun);
4063 CHECK_OFFSET(si_value);
4064
4065 /* rt */
4066 CHECK_OFFSET(si_pid);
4067 CHECK_OFFSET(si_uid);
4068 CHECK_OFFSET(si_value);
4069
4070 /* sigchld */
4071 CHECK_OFFSET(si_pid);
4072 CHECK_OFFSET(si_uid);
4073 CHECK_OFFSET(si_status);
4074 CHECK_OFFSET(si_utime);
4075 CHECK_OFFSET(si_stime);
4076
4077 /* sigfault */
4078 CHECK_OFFSET(si_addr);
4079 CHECK_OFFSET(si_addr_lsb);
4080 CHECK_OFFSET(si_lower);
4081 CHECK_OFFSET(si_upper);
4082 CHECK_OFFSET(si_pkey);
4083
4084 /* sigpoll */
4085 CHECK_OFFSET(si_band);
4086 CHECK_OFFSET(si_fd);
4087
4088 /* sigsys */
4089 CHECK_OFFSET(si_call_addr);
4090 CHECK_OFFSET(si_syscall);
4091 CHECK_OFFSET(si_arch);
4092#undef CHECK_OFFSET
4093}
4094
4095void __init signals_init(void)
4096{
4097 siginfo_buildtime_checks();
4098
3976 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC); 4099 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
3977} 4100}
3978 4101