aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2018-09-25 05:27:20 -0400
committerEric W. Biederman <ebiederm@xmission.com>2018-10-03 10:47:43 -0400
commitae7795bc6187a15ec51cf258abae656a625f9980 (patch)
tree2456aa85c6b4be1ac58e272393056c0edbee038a /kernel
parent4cd2e0e70af6897ca2247fa1ffb1553ca16b4903 (diff)
signal: Distinguish between kernel_siginfo and siginfo
Linus recently observed that if we did not worry about the padding member in struct siginfo it is only about 48 bytes, and 48 bytes is much nicer than 128 bytes for allocating on the stack and copying around in the kernel. The obvious thing of only adding the padding when userspace is including siginfo.h won't work as there are sigframe definitions in the kernel that embed struct siginfo. So split siginfo in two; kernel_siginfo and siginfo. Keeping the traditional name for the userspace definition. While the version that is used internally to the kernel and ultimately will not be padded to 128 bytes is called kernel_siginfo. The definition of struct kernel_siginfo I have put in include/signal_types.h A set of buildtime checks has been added to verify the two structures have the same field offsets. To make it easy to verify the change kernel_siginfo retains the same size as siginfo. The reduction in size comes in a following change. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/ptrace.c10
-rw-r--r--kernel/seccomp.c6
-rw-r--r--kernel/signal.c151
-rw-r--r--kernel/time/posix-timers.c2
4 files changed, 108 insertions, 61 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index a807ff5cc1a9..c2cee9db5204 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -651,7 +651,7 @@ static int ptrace_setoptions(struct task_struct *child, unsigned long data)
651 return 0; 651 return 0;
652} 652}
653 653
654static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info) 654static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
655{ 655{
656 unsigned long flags; 656 unsigned long flags;
657 int error = -ESRCH; 657 int error = -ESRCH;
@@ -667,7 +667,7 @@ static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
667 return error; 667 return error;
668} 668}
669 669
670static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info) 670static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
671{ 671{
672 unsigned long flags; 672 unsigned long flags;
673 int error = -ESRCH; 673 int error = -ESRCH;
@@ -709,7 +709,7 @@ static int ptrace_peek_siginfo(struct task_struct *child,
709 pending = &child->pending; 709 pending = &child->pending;
710 710
711 for (i = 0; i < arg.nr; ) { 711 for (i = 0; i < arg.nr; ) {
712 siginfo_t info; 712 kernel_siginfo_t info;
713 s32 off = arg.off + i; 713 s32 off = arg.off + i;
714 714
715 spin_lock_irq(&child->sighand->siglock); 715 spin_lock_irq(&child->sighand->siglock);
@@ -885,7 +885,7 @@ int ptrace_request(struct task_struct *child, long request,
885{ 885{
886 bool seized = child->ptrace & PT_SEIZED; 886 bool seized = child->ptrace & PT_SEIZED;
887 int ret = -EIO; 887 int ret = -EIO;
888 siginfo_t siginfo, *si; 888 kernel_siginfo_t siginfo, *si;
889 void __user *datavp = (void __user *) data; 889 void __user *datavp = (void __user *) data;
890 unsigned long __user *datalp = datavp; 890 unsigned long __user *datalp = datavp;
891 unsigned long flags; 891 unsigned long flags;
@@ -1180,7 +1180,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1180{ 1180{
1181 compat_ulong_t __user *datap = compat_ptr(data); 1181 compat_ulong_t __user *datap = compat_ptr(data);
1182 compat_ulong_t word; 1182 compat_ulong_t word;
1183 siginfo_t siginfo; 1183 kernel_siginfo_t siginfo;
1184 int ret; 1184 int ret;
1185 1185
1186 switch (request) { 1186 switch (request) {
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index fd023ac24e10..4d7809cdd27d 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -522,7 +522,7 @@ void put_seccomp_filter(struct task_struct *tsk)
522 __put_seccomp_filter(tsk->seccomp.filter); 522 __put_seccomp_filter(tsk->seccomp.filter);
523} 523}
524 524
525static void seccomp_init_siginfo(siginfo_t *info, int syscall, int reason) 525static void seccomp_init_siginfo(kernel_siginfo_t *info, int syscall, int reason)
526{ 526{
527 clear_siginfo(info); 527 clear_siginfo(info);
528 info->si_signo = SIGSYS; 528 info->si_signo = SIGSYS;
@@ -542,7 +542,7 @@ static void seccomp_init_siginfo(siginfo_t *info, int syscall, int reason)
542 */ 542 */
543static void seccomp_send_sigsys(int syscall, int reason) 543static void seccomp_send_sigsys(int syscall, int reason)
544{ 544{
545 struct siginfo info; 545 struct kernel_siginfo info;
546 seccomp_init_siginfo(&info, syscall, reason); 546 seccomp_init_siginfo(&info, syscall, reason);
547 force_sig_info(SIGSYS, &info, current); 547 force_sig_info(SIGSYS, &info, current);
548} 548}
@@ -747,7 +747,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
747 /* Dump core only if this is the last remaining thread. */ 747 /* Dump core only if this is the last remaining thread. */
748 if (action == SECCOMP_RET_KILL_PROCESS || 748 if (action == SECCOMP_RET_KILL_PROCESS ||
749 get_nr_threads(current) == 1) { 749 get_nr_threads(current) == 1) {
750 siginfo_t info; 750 kernel_siginfo_t info;
751 751
752 /* Show the original registers in the dump. */ 752 /* Show the original registers in the dump. */
753 syscall_rollback(current, task_pt_regs(current)); 753 syscall_rollback(current, task_pt_regs(current));
diff --git a/kernel/signal.c b/kernel/signal.c
index c0e289e62d77..161cad4e448c 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -549,7 +549,7 @@ bool unhandled_signal(struct task_struct *tsk, int sig)
549 return !tsk->ptrace; 549 return !tsk->ptrace;
550} 550}
551 551
552static void collect_signal(int sig, struct sigpending *list, siginfo_t *info, 552static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info,
553 bool *resched_timer) 553 bool *resched_timer)
554{ 554{
555 struct sigqueue *q, *first = NULL; 555 struct sigqueue *q, *first = NULL;
@@ -595,7 +595,7 @@ still_pending:
595} 595}
596 596
597static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, 597static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
598 siginfo_t *info, bool *resched_timer) 598 kernel_siginfo_t *info, bool *resched_timer)
599{ 599{
600 int sig = next_signal(pending, mask); 600 int sig = next_signal(pending, mask);
601 601
@@ -610,7 +610,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
610 * 610 *
611 * All callers have to hold the siglock. 611 * All callers have to hold the siglock.
612 */ 612 */
613int 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)
614{ 614{
615 bool resched_timer = false; 615 bool resched_timer = false;
616 int signr; 616 int signr;
@@ -737,12 +737,12 @@ static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
737 } 737 }
738} 738}
739 739
740static inline int is_si_special(const struct siginfo *info) 740static inline int is_si_special(const struct kernel_siginfo *info)
741{ 741{
742 return info <= SEND_SIG_PRIV; 742 return info <= SEND_SIG_PRIV;
743} 743}
744 744
745static inline bool si_fromuser(const struct siginfo *info) 745static inline bool si_fromuser(const struct kernel_siginfo *info)
746{ 746{
747 return info == SEND_SIG_NOINFO || 747 return info == SEND_SIG_NOINFO ||
748 (!is_si_special(info) && SI_FROMUSER(info)); 748 (!is_si_special(info) && SI_FROMUSER(info));
@@ -767,7 +767,7 @@ static bool kill_ok_by_cred(struct task_struct *t)
767 * Bad permissions for sending the signal 767 * Bad permissions for sending the signal
768 * - the caller must hold the RCU read lock 768 * - the caller must hold the RCU read lock
769 */ 769 */
770static int check_kill_permission(int sig, struct siginfo *info, 770static int check_kill_permission(int sig, struct kernel_siginfo *info,
771 struct task_struct *t) 771 struct task_struct *t)
772{ 772{
773 struct pid *sid; 773 struct pid *sid;
@@ -1010,7 +1010,7 @@ static inline bool legacy_queue(struct sigpending *signals, int sig)
1010} 1010}
1011 1011
1012#ifdef CONFIG_USER_NS 1012#ifdef CONFIG_USER_NS
1013static 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)
1014{ 1014{
1015 if (current_user_ns() == task_cred_xxx(t, user_ns)) 1015 if (current_user_ns() == task_cred_xxx(t, user_ns))
1016 return; 1016 return;
@@ -1024,13 +1024,13 @@ static inline void userns_fixup_signal_uid(struct siginfo *info, struct task_str
1024 rcu_read_unlock(); 1024 rcu_read_unlock();
1025} 1025}
1026#else 1026#else
1027static 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)
1028{ 1028{
1029 return; 1029 return;
1030} 1030}
1031#endif 1031#endif
1032 1032
1033static 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,
1034 enum pid_type type, int from_ancestor_ns) 1034 enum pid_type type, int from_ancestor_ns)
1035{ 1035{
1036 struct sigpending *pending; 1036 struct sigpending *pending;
@@ -1150,7 +1150,7 @@ ret:
1150 return ret; 1150 return ret;
1151} 1151}
1152 1152
1153static 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,
1154 enum pid_type type) 1154 enum pid_type type)
1155{ 1155{
1156 int from_ancestor_ns = 0; 1156 int from_ancestor_ns = 0;
@@ -1197,12 +1197,12 @@ static int __init setup_print_fatal_signals(char *str)
1197__setup("print-fatal-signals=", setup_print_fatal_signals); 1197__setup("print-fatal-signals=", setup_print_fatal_signals);
1198 1198
1199int 1199int
1200__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)
1201{ 1201{
1202 return send_signal(sig, info, p, PIDTYPE_TGID); 1202 return send_signal(sig, info, p, PIDTYPE_TGID);
1203} 1203}
1204 1204
1205int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p, 1205int do_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p,
1206 enum pid_type type) 1206 enum pid_type type)
1207{ 1207{
1208 unsigned long flags; 1208 unsigned long flags;
@@ -1228,7 +1228,7 @@ int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
1228 * that is why we also clear SIGNAL_UNKILLABLE. 1228 * that is why we also clear SIGNAL_UNKILLABLE.
1229 */ 1229 */
1230int 1230int
1231force_sig_info(int sig, struct siginfo *info, struct task_struct *t) 1231force_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *t)
1232{ 1232{
1233 unsigned long int flags; 1233 unsigned long int flags;
1234 int ret, blocked, ignored; 1234 int ret, blocked, ignored;
@@ -1316,8 +1316,8 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
1316/* 1316/*
1317 * send signal info to all the members of a group 1317 * send signal info to all the members of a group
1318 */ 1318 */
1319int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p, 1319int group_send_sig_info(int sig, struct kernel_siginfo *info,
1320 enum pid_type type) 1320 struct task_struct *p, enum pid_type type)
1321{ 1321{
1322 int ret; 1322 int ret;
1323 1323
@@ -1336,7 +1336,7 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p,
1336 * control characters do (^C, ^Z etc) 1336 * control characters do (^C, ^Z etc)
1337 * - the caller must hold at least a readlock on tasklist_lock 1337 * - the caller must hold at least a readlock on tasklist_lock
1338 */ 1338 */
1339int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp) 1339int __kill_pgrp_info(int sig, struct kernel_siginfo *info, struct pid *pgrp)
1340{ 1340{
1341 struct task_struct *p = NULL; 1341 struct task_struct *p = NULL;
1342 int retval, success; 1342 int retval, success;
@@ -1351,7 +1351,7 @@ int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp)
1351 return success ? 0 : retval; 1351 return success ? 0 : retval;
1352} 1352}
1353 1353
1354int kill_pid_info(int sig, struct siginfo *info, struct pid *pid) 1354int kill_pid_info(int sig, struct kernel_siginfo *info, struct pid *pid)
1355{ 1355{
1356 int error = -ESRCH; 1356 int error = -ESRCH;
1357 struct task_struct *p; 1357 struct task_struct *p;
@@ -1373,7 +1373,7 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
1373 } 1373 }
1374} 1374}
1375 1375
1376static 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)
1377{ 1377{
1378 int error; 1378 int error;
1379 rcu_read_lock(); 1379 rcu_read_lock();
@@ -1394,7 +1394,7 @@ static inline bool kill_as_cred_perm(const struct cred *cred,
1394} 1394}
1395 1395
1396/* 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" */
1397int 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,
1398 const struct cred *cred) 1398 const struct cred *cred)
1399{ 1399{
1400 int ret = -EINVAL; 1400 int ret = -EINVAL;
@@ -1438,7 +1438,7 @@ EXPORT_SYMBOL_GPL(kill_pid_info_as_cred);
1438 * is probably wrong. Should make it like BSD or SYSV. 1438 * is probably wrong. Should make it like BSD or SYSV.
1439 */ 1439 */
1440 1440
1441static 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)
1442{ 1442{
1443 int ret; 1443 int ret;
1444 1444
@@ -1482,7 +1482,7 @@ static int kill_something_info(int sig, struct siginfo *info, pid_t pid)
1482 * 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.
1483 */ 1483 */
1484 1484
1485int 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)
1486{ 1486{
1487 /* 1487 /*
1488 * Make sure legacy kernel users don't send in bad values 1488 * Make sure legacy kernel users don't send in bad values
@@ -1533,7 +1533,7 @@ int force_sig_fault(int sig, int code, void __user *addr
1533 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) 1533 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
1534 , struct task_struct *t) 1534 , struct task_struct *t)
1535{ 1535{
1536 struct siginfo info; 1536 struct kernel_siginfo info;
1537 1537
1538 clear_siginfo(&info); 1538 clear_siginfo(&info);
1539 info.si_signo = sig; 1539 info.si_signo = sig;
@@ -1556,7 +1556,7 @@ int send_sig_fault(int sig, int code, void __user *addr
1556 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) 1556 ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
1557 , struct task_struct *t) 1557 , struct task_struct *t)
1558{ 1558{
1559 struct siginfo info; 1559 struct kernel_siginfo info;
1560 1560
1561 clear_siginfo(&info); 1561 clear_siginfo(&info);
1562 info.si_signo = sig; 1562 info.si_signo = sig;
@@ -1576,7 +1576,7 @@ int send_sig_fault(int sig, int code, void __user *addr
1576 1576
1577int 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)
1578{ 1578{
1579 struct siginfo info; 1579 struct kernel_siginfo info;
1580 1580
1581 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR)); 1581 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
1582 clear_siginfo(&info); 1582 clear_siginfo(&info);
@@ -1590,7 +1590,7 @@ int force_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct
1590 1590
1591int 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)
1592{ 1592{
1593 struct siginfo info; 1593 struct kernel_siginfo info;
1594 1594
1595 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR)); 1595 WARN_ON((code != BUS_MCEERR_AO) && (code != BUS_MCEERR_AR));
1596 clear_siginfo(&info); 1596 clear_siginfo(&info);
@@ -1605,7 +1605,7 @@ EXPORT_SYMBOL(send_sig_mceerr);
1605 1605
1606int 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)
1607{ 1607{
1608 struct siginfo info; 1608 struct kernel_siginfo info;
1609 1609
1610 clear_siginfo(&info); 1610 clear_siginfo(&info);
1611 info.si_signo = SIGSEGV; 1611 info.si_signo = SIGSEGV;
@@ -1620,7 +1620,7 @@ int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper)
1620#ifdef SEGV_PKUERR 1620#ifdef SEGV_PKUERR
1621int force_sig_pkuerr(void __user *addr, u32 pkey) 1621int force_sig_pkuerr(void __user *addr, u32 pkey)
1622{ 1622{
1623 struct siginfo info; 1623 struct kernel_siginfo info;
1624 1624
1625 clear_siginfo(&info); 1625 clear_siginfo(&info);
1626 info.si_signo = SIGSEGV; 1626 info.si_signo = SIGSEGV;
@@ -1637,7 +1637,7 @@ int force_sig_pkuerr(void __user *addr, u32 pkey)
1637 */ 1637 */
1638int force_sig_ptrace_errno_trap(int errno, void __user *addr) 1638int force_sig_ptrace_errno_trap(int errno, void __user *addr)
1639{ 1639{
1640 struct siginfo info; 1640 struct kernel_siginfo info;
1641 1641
1642 clear_siginfo(&info); 1642 clear_siginfo(&info);
1643 info.si_signo = SIGTRAP; 1643 info.si_signo = SIGTRAP;
@@ -1766,7 +1766,7 @@ ret:
1766 */ 1766 */
1767bool do_notify_parent(struct task_struct *tsk, int sig) 1767bool do_notify_parent(struct task_struct *tsk, int sig)
1768{ 1768{
1769 struct siginfo info; 1769 struct kernel_siginfo info;
1770 unsigned long flags; 1770 unsigned long flags;
1771 struct sighand_struct *psig; 1771 struct sighand_struct *psig;
1772 bool autoreap = false; 1772 bool autoreap = false;
@@ -1871,7 +1871,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
1871static void do_notify_parent_cldstop(struct task_struct *tsk, 1871static void do_notify_parent_cldstop(struct task_struct *tsk,
1872 bool for_ptracer, int why) 1872 bool for_ptracer, int why)
1873{ 1873{
1874 struct siginfo info; 1874 struct kernel_siginfo info;
1875 unsigned long flags; 1875 unsigned long flags;
1876 struct task_struct *parent; 1876 struct task_struct *parent;
1877 struct sighand_struct *sighand; 1877 struct sighand_struct *sighand;
@@ -1971,7 +1971,7 @@ static bool sigkill_pending(struct task_struct *tsk)
1971 * 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
1972 * is gone, we keep current->exit_code unless clear_code. 1972 * is gone, we keep current->exit_code unless clear_code.
1973 */ 1973 */
1974static 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)
1975 __releases(&current->sighand->siglock) 1975 __releases(&current->sighand->siglock)
1976 __acquires(&current->sighand->siglock) 1976 __acquires(&current->sighand->siglock)
1977{ 1977{
@@ -2108,7 +2108,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
2108 2108
2109static void ptrace_do_notify(int signr, int exit_code, int why) 2109static void ptrace_do_notify(int signr, int exit_code, int why)
2110{ 2110{
2111 siginfo_t info; 2111 kernel_siginfo_t info;
2112 2112
2113 clear_siginfo(&info); 2113 clear_siginfo(&info);
2114 info.si_signo = signr; 2114 info.si_signo = signr;
@@ -2289,7 +2289,7 @@ static void do_jobctl_trap(void)
2289 } 2289 }
2290} 2290}
2291 2291
2292static int ptrace_signal(int signr, siginfo_t *info) 2292static int ptrace_signal(int signr, kernel_siginfo_t *info)
2293{ 2293{
2294 /* 2294 /*
2295 * 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
@@ -2889,14 +2889,14 @@ enum siginfo_layout siginfo_layout(int sig, int si_code)
2889 return layout; 2889 return layout;
2890} 2890}
2891 2891
2892int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from) 2892int copy_siginfo_to_user(siginfo_t __user *to, const kernel_siginfo_t *from)
2893{ 2893{
2894 if (copy_to_user(to, from , sizeof(struct siginfo))) 2894 if (copy_to_user(to, from , sizeof(struct kernel_siginfo)))
2895 return -EFAULT; 2895 return -EFAULT;
2896 return 0; 2896 return 0;
2897} 2897}
2898 2898
2899int copy_siginfo_from_user(siginfo_t *to, const siginfo_t __user *from) 2899int copy_siginfo_from_user(kernel_siginfo_t *to, const siginfo_t __user *from)
2900{ 2900{
2901 if (copy_from_user(to, from, sizeof(struct siginfo))) 2901 if (copy_from_user(to, from, sizeof(struct siginfo)))
2902 return -EFAULT; 2902 return -EFAULT;
@@ -2905,13 +2905,13 @@ int copy_siginfo_from_user(siginfo_t *to, const siginfo_t __user *from)
2905 2905
2906#ifdef CONFIG_COMPAT 2906#ifdef CONFIG_COMPAT
2907int copy_siginfo_to_user32(struct compat_siginfo __user *to, 2907int copy_siginfo_to_user32(struct compat_siginfo __user *to,
2908 const struct siginfo *from) 2908 const struct kernel_siginfo *from)
2909#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION) 2909#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION)
2910{ 2910{
2911 return __copy_siginfo_to_user32(to, from, in_x32_syscall()); 2911 return __copy_siginfo_to_user32(to, from, in_x32_syscall());
2912} 2912}
2913int __copy_siginfo_to_user32(struct compat_siginfo __user *to, 2913int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
2914 const struct siginfo *from, bool x32_ABI) 2914 const struct kernel_siginfo *from, bool x32_ABI)
2915#endif 2915#endif
2916{ 2916{
2917 struct compat_siginfo new; 2917 struct compat_siginfo new;
@@ -2995,7 +2995,7 @@ int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
2995 return 0; 2995 return 0;
2996} 2996}
2997 2997
2998int copy_siginfo_from_user32(struct siginfo *to, 2998int copy_siginfo_from_user32(struct kernel_siginfo *to,
2999 const struct compat_siginfo __user *ufrom) 2999 const struct compat_siginfo __user *ufrom)
3000{ 3000{
3001 struct compat_siginfo from; 3001 struct compat_siginfo from;
@@ -3085,7 +3085,7 @@ int copy_siginfo_from_user32(struct siginfo *to,
3085 * @info: if non-null, the signal's siginfo is returned here 3085 * @info: if non-null, the signal's siginfo is returned here
3086 * @ts: upper bound on process time suspension 3086 * @ts: upper bound on process time suspension
3087 */ 3087 */
3088static int do_sigtimedwait(const sigset_t *which, siginfo_t *info, 3088static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,
3089 const struct timespec *ts) 3089 const struct timespec *ts)
3090{ 3090{
3091 ktime_t *to = NULL, timeout = KTIME_MAX; 3091 ktime_t *to = NULL, timeout = KTIME_MAX;
@@ -3149,7 +3149,7 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const sigset_t __user *, uthese,
3149{ 3149{
3150 sigset_t these; 3150 sigset_t these;
3151 struct timespec ts; 3151 struct timespec ts;
3152 siginfo_t info; 3152 kernel_siginfo_t info;
3153 int ret; 3153 int ret;
3154 3154
3155 /* XXX: Don't preclude handling different sized sigset_t's. */ 3155 /* XXX: Don't preclude handling different sized sigset_t's. */
@@ -3181,7 +3181,7 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
3181{ 3181{
3182 sigset_t s; 3182 sigset_t s;
3183 struct timespec t; 3183 struct timespec t;
3184 siginfo_t info; 3184 kernel_siginfo_t info;
3185 long ret; 3185 long ret;
3186 3186
3187 if (sigsetsize != sizeof(sigset_t)) 3187 if (sigsetsize != sizeof(sigset_t))
@@ -3213,7 +3213,7 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
3213 */ 3213 */
3214SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) 3214SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
3215{ 3215{
3216 struct siginfo info; 3216 struct kernel_siginfo info;
3217 3217
3218 clear_siginfo(&info); 3218 clear_siginfo(&info);
3219 info.si_signo = sig; 3219 info.si_signo = sig;
@@ -3226,7 +3226,7 @@ SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
3226} 3226}
3227 3227
3228static int 3228static int
3229do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info) 3229do_send_specific(pid_t tgid, pid_t pid, int sig, struct kernel_siginfo *info)
3230{ 3230{
3231 struct task_struct *p; 3231 struct task_struct *p;
3232 int error = -ESRCH; 3232 int error = -ESRCH;
@@ -3257,7 +3257,7 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
3257 3257
3258static int do_tkill(pid_t tgid, pid_t pid, int sig) 3258static int do_tkill(pid_t tgid, pid_t pid, int sig)
3259{ 3259{
3260 struct siginfo info; 3260 struct kernel_siginfo info;
3261 3261
3262 clear_siginfo(&info); 3262 clear_siginfo(&info);
3263 info.si_signo = sig; 3263 info.si_signo = sig;
@@ -3304,7 +3304,7 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, sig)
3304 return do_tkill(0, pid, sig); 3304 return do_tkill(0, pid, sig);
3305} 3305}
3306 3306
3307static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info) 3307static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t *info)
3308{ 3308{
3309 /* Not even root can pretend to send signals from the kernel. 3309 /* Not even root can pretend to send signals from the kernel.
3310 * Nor can they impersonate a kill()/tgkill(), which adds source info. 3310 * Nor can they impersonate a kill()/tgkill(), which adds source info.
@@ -3329,7 +3329,7 @@ static int do_rt_sigqueueinfo(pid_t pid, int sig, siginfo_t *info)
3329SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig, 3329SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t, pid, int, sig,
3330 siginfo_t __user *, uinfo) 3330 siginfo_t __user *, uinfo)
3331{ 3331{
3332 siginfo_t info; 3332 kernel_siginfo_t info;
3333 int ret = copy_siginfo_from_user(&info, uinfo); 3333 int ret = copy_siginfo_from_user(&info, uinfo);
3334 if (unlikely(ret)) 3334 if (unlikely(ret))
3335 return ret; 3335 return ret;
@@ -3342,7 +3342,7 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
3342 int, sig, 3342 int, sig,
3343 struct compat_siginfo __user *, uinfo) 3343 struct compat_siginfo __user *, uinfo)
3344{ 3344{
3345 siginfo_t info; 3345 kernel_siginfo_t info;
3346 int ret = copy_siginfo_from_user32(&info, uinfo); 3346 int ret = copy_siginfo_from_user32(&info, uinfo);
3347 if (unlikely(ret)) 3347 if (unlikely(ret))
3348 return ret; 3348 return ret;
@@ -3350,7 +3350,7 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo,
3350} 3350}
3351#endif 3351#endif
3352 3352
3353static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info) 3353static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, kernel_siginfo_t *info)
3354{ 3354{
3355 /* This is only valid for single tasks */ 3355 /* This is only valid for single tasks */
3356 if (pid <= 0 || tgid <= 0) 3356 if (pid <= 0 || tgid <= 0)
@@ -3372,7 +3372,7 @@ static int do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
3372SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig, 3372SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig,
3373 siginfo_t __user *, uinfo) 3373 siginfo_t __user *, uinfo)
3374{ 3374{
3375 siginfo_t info; 3375 kernel_siginfo_t info;
3376 int ret = copy_siginfo_from_user(&info, uinfo); 3376 int ret = copy_siginfo_from_user(&info, uinfo);
3377 if (unlikely(ret)) 3377 if (unlikely(ret))
3378 return ret; 3378 return ret;
@@ -3386,7 +3386,7 @@ COMPAT_SYSCALL_DEFINE4(rt_tgsigqueueinfo,
3386 int, sig, 3386 int, sig,
3387 struct compat_siginfo __user *, uinfo) 3387 struct compat_siginfo __user *, uinfo)
3388{ 3388{
3389 siginfo_t info; 3389 kernel_siginfo_t info;
3390 int ret = copy_siginfo_from_user32(&info, uinfo); 3390 int ret = copy_siginfo_from_user32(&info, uinfo);
3391 if (unlikely(ret)) 3391 if (unlikely(ret))
3392 return ret; 3392 return ret;
@@ -3968,10 +3968,57 @@ __weak const char *arch_vma_name(struct vm_area_struct *vma)
3968 return NULL; 3968 return NULL;
3969} 3969}
3970 3970
3971void __init signals_init(void) 3971static inline void siginfo_buildtime_checks(void)
3972{ 3972{
3973 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE); 3973 BUILD_BUG_ON(sizeof(struct siginfo) != SI_MAX_SIZE);
3974 3974
3975 /* Verify the offsets in the two siginfos match */
3976#define CHECK_OFFSET(field) \
3977 BUILD_BUG_ON(offsetof(siginfo_t, field) != offsetof(kernel_siginfo_t, field))
3978
3979 /* kill */
3980 CHECK_OFFSET(si_pid);
3981 CHECK_OFFSET(si_uid);
3982
3983 /* timer */
3984 CHECK_OFFSET(si_tid);
3985 CHECK_OFFSET(si_overrun);
3986 CHECK_OFFSET(si_value);
3987
3988 /* rt */
3989 CHECK_OFFSET(si_pid);
3990 CHECK_OFFSET(si_uid);
3991 CHECK_OFFSET(si_value);
3992
3993 /* sigchld */
3994 CHECK_OFFSET(si_pid);
3995 CHECK_OFFSET(si_uid);
3996 CHECK_OFFSET(si_status);
3997 CHECK_OFFSET(si_utime);
3998 CHECK_OFFSET(si_stime);
3999
4000 /* sigfault */
4001 CHECK_OFFSET(si_addr);
4002 CHECK_OFFSET(si_addr_lsb);
4003 CHECK_OFFSET(si_lower);
4004 CHECK_OFFSET(si_upper);
4005 CHECK_OFFSET(si_pkey);
4006
4007 /* sigpoll */
4008 CHECK_OFFSET(si_band);
4009 CHECK_OFFSET(si_fd);
4010
4011 /* sigsys */
4012 CHECK_OFFSET(si_call_addr);
4013 CHECK_OFFSET(si_syscall);
4014 CHECK_OFFSET(si_arch);
4015#undef CHECK_OFFSET
4016}
4017
4018void __init signals_init(void)
4019{
4020 siginfo_buildtime_checks();
4021
3975 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC); 4022 sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
3976} 4023}
3977 4024
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 4b9127e95430..eabb4c22728d 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -308,7 +308,7 @@ static void common_hrtimer_rearm(struct k_itimer *timr)
308 * To protect against the timer going away while the interrupt is queued, 308 * To protect against the timer going away while the interrupt is queued,
309 * we require that the it_requeue_pending flag be set. 309 * we require that the it_requeue_pending flag be set.
310 */ 310 */
311void posixtimer_rearm(struct siginfo *info) 311void posixtimer_rearm(struct kernel_siginfo *info)
312{ 312{
313 struct k_itimer *timr; 313 struct k_itimer *timr;
314 unsigned long flags; 314 unsigned long flags;