aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2017-08-05 16:00:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-08-06 14:48:27 -0400
commitfbb77611e95d3d5b2af86a59754a3130877cb667 (patch)
tree026bc121b112736776c5de03463ce52fa4424280
parent0fdd951c9bef93637d5af036851e7a5632fbd6c3 (diff)
Fix compat_sys_sigpending breakage
The latest change of compat_sys_sigpending in commit 8f13621abced ("sigpending(): move compat to native") has broken it in two ways. First, it tries to write 4 bytes more than userspace expects: sizeof(old_sigset_t) == sizeof(long) == 8 instead of sizeof(compat_old_sigset_t) == sizeof(u32) == 4. Second, on big endian architectures these bytes are being written in the wrong order. This bug was found by strace test suite. Reported-by: Anatoly Pugachev <matorola@gmail.com> Inspired-by: Eugene Syromyatnikov <evgsyr@gmail.com> Fixes: 8f13621abced ("sigpending(): move compat to native") Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Acked-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/signal.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index caed9133ae52..7e33f8c583e6 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3303,12 +3303,15 @@ SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set)
3303#ifdef CONFIG_COMPAT 3303#ifdef CONFIG_COMPAT
3304COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32) 3304COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
3305{ 3305{
3306#ifdef __BIG_ENDIAN
3306 sigset_t set; 3307 sigset_t set;
3307 int err = do_sigpending(&set, sizeof(old_sigset_t)); 3308 int err = do_sigpending(&set, sizeof(set.sig[0]));
3308 if (err == 0) 3309 if (!err)
3309 if (copy_to_user(set32, &set, sizeof(old_sigset_t))) 3310 err = put_user(set.sig[0], set32);
3310 err = -EFAULT;
3311 return err; 3311 return err;
3312#else
3313 return sys_rt_sigpending((sigset_t __user *)set32, sizeof(*set32));
3314#endif
3312} 3315}
3313#endif 3316#endif
3314 3317