public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix compat_sys_sigpending breakage introduced by v4.13-rc1~6^2~12
@ 2017-08-05 20:00 Dmitry V. Levin
  2017-08-06 18:22 ` Al Viro
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry V. Levin @ 2017-08-05 20:00 UTC (permalink / raw)
  To: Al Viro
  Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, sparclinux,
	linux-kernel, Anatoly Pugachev, Eugene Syromyatnikov

The latest change of compat_sys_sigpending 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>
---
 kernel/signal.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index caed913..7e33f8c 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3303,12 +3303,15 @@ SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set)
 #ifdef CONFIG_COMPAT
 COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
 {
+#ifdef __BIG_ENDIAN
 	sigset_t set;
-	int err = do_sigpending(&set, sizeof(old_sigset_t)); 
-	if (err == 0)
-		if (copy_to_user(set32, &set, sizeof(old_sigset_t)))
-			err = -EFAULT;
+	int err = do_sigpending(&set, sizeof(set.sig[0]));
+	if (!err)
+		err = put_user(set.sig[0], set32);
 	return err;
+#else
+	return sys_rt_sigpending((sigset_t __user *)set32, sizeof(*set32));
+#endif
 }
 #endif
 
-- 
ldv

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-08-28 15:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-05 20:00 [PATCH] Fix compat_sys_sigpending breakage introduced by v4.13-rc1~6^2~12 Dmitry V. Levin
2017-08-06 18:22 ` Al Viro
2017-08-06 18:46   ` Linus Torvalds
2017-08-21 23:09   ` Dmitry V. Levin
2017-08-21 23:16     ` [PATCH 1/3] signal: replace sigset_to_compat() with put_compat_sigset() Dmitry V. Levin
2017-08-21 23:16     ` [PATCH 2/3] signal: simplify compat_sigpending() Dmitry V. Levin
2017-08-21 23:16     ` [PATCH 3/3] signal: lift sigset size check out of do_sigpending() Dmitry V. Levin
2017-08-28  4:41   ` [PATCH] Fix compat_sys_sigpending breakage introduced by v4.13-rc1~6^2~12 Al Viro
2017-08-28 15:27     ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox