All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "cris: buggered copy_from_user/copy_to_user/clear_user" has been added to the 4.7-stable tree
@ 2016-09-22 15:42 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2016-09-22 15:42 UTC (permalink / raw)
  To: viro, gregkh, jesper.nilsson; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    cris: buggered copy_from_user/copy_to_user/clear_user

to the 4.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     cris-buggered-copy_from_user-copy_to_user-clear_user.patch
and it can be found in the queue-4.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From eb47e0293baaa3044022059f1fa9ff474bfe35cb Mon Sep 17 00:00:00 2001
From: Al Viro <viro@zeniv.linux.org.uk>
Date: Thu, 18 Aug 2016 19:34:00 -0400
Subject: cris: buggered copy_from_user/copy_to_user/clear_user

From: Al Viro <viro@zeniv.linux.org.uk>

commit eb47e0293baaa3044022059f1fa9ff474bfe35cb upstream.

* copy_from_user() on access_ok() failure ought to zero the destination
* none of those primitives should skip the access_ok() check in case of
small constant size.

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/cris/include/asm/uaccess.h |   75 ++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 41 deletions(-)

--- a/arch/cris/include/asm/uaccess.h
+++ b/arch/cris/include/asm/uaccess.h
@@ -194,30 +194,6 @@ extern unsigned long __copy_user(void __
 extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n);
 extern unsigned long __do_clear_user(void __user *to, unsigned long n);
 
-static inline unsigned long
-__generic_copy_to_user(void __user *to, const void *from, unsigned long n)
-{
-	if (access_ok(VERIFY_WRITE, to, n))
-		return __copy_user(to, from, n);
-	return n;
-}
-
-static inline unsigned long
-__generic_copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-	if (access_ok(VERIFY_READ, from, n))
-		return __copy_user_zeroing(to, from, n);
-	return n;
-}
-
-static inline unsigned long
-__generic_clear_user(void __user *to, unsigned long n)
-{
-	if (access_ok(VERIFY_WRITE, to, n))
-		return __do_clear_user(to, n);
-	return n;
-}
-
 static inline long
 __strncpy_from_user(char *dst, const char __user *src, long count)
 {
@@ -282,7 +258,7 @@ __constant_copy_from_user(void *to, cons
 	else if (n == 24)
 		__asm_copy_from_user_24(to, from, ret);
 	else
-		ret = __generic_copy_from_user(to, from, n);
+		ret = __copy_user_zeroing(to, from, n);
 
 	return ret;
 }
@@ -333,7 +309,7 @@ __constant_copy_to_user(void __user *to,
 	else if (n == 24)
 		__asm_copy_to_user_24(to, from, ret);
 	else
-		ret = __generic_copy_to_user(to, from, n);
+		ret = __copy_user(to, from, n);
 
 	return ret;
 }
@@ -366,26 +342,43 @@ __constant_clear_user(void __user *to, u
 	else if (n == 24)
 		__asm_clear_24(to, ret);
 	else
-		ret = __generic_clear_user(to, n);
+		ret = __do_clear_user(to, n);
 
 	return ret;
 }
 
 
-#define clear_user(to, n)				\
-	(__builtin_constant_p(n) ?			\
-	 __constant_clear_user(to, n) :			\
-	 __generic_clear_user(to, n))
-
-#define copy_from_user(to, from, n)			\
-	(__builtin_constant_p(n) ?			\
-	 __constant_copy_from_user(to, from, n) :	\
-	 __generic_copy_from_user(to, from, n))
-
-#define copy_to_user(to, from, n)			\
-	(__builtin_constant_p(n) ?			\
-	 __constant_copy_to_user(to, from, n) :		\
-	 __generic_copy_to_user(to, from, n))
+static inline size_t clear_user(void __user *to, size_t n)
+{
+	if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
+		return n;
+	if (__builtin_constant_p(n))
+		return __constant_clear_user(to, n);
+	else
+		return __do_clear_user(to, n);
+}
+
+static inline size_t copy_from_user(void *to, const void __user *from, size_t n)
+{
+	if (unlikely(!access_ok(VERIFY_READ, from, n))) {
+		memset(to, 0, n);
+		return n;
+	}
+	if (__builtin_constant_p(n))
+		return __constant_copy_from_user(to, from, n);
+	else
+		return __copy_user_zeroing(to, from, n);
+}
+
+static inline size_t copy_to_user(void __user *to, const void *from, size_t n)
+{
+	if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
+		return n;
+	if (__builtin_constant_p(n))
+		return __constant_copy_to_user(to, from, n);
+	else
+		return __copy_user(to, from, n);
+}
 
 /* We let the __ versions of copy_from/to_user inline, because they're often
  * used in fast paths and have only a small space overhead.


Patches currently in stable-queue which might be from viro@zeniv.linux.org.uk are

queue-4.7/nios2-copy_from_user-should-zero-the-tail-of-destination.patch
queue-4.7/m32r-fix-__get_user.patch
queue-4.7/microblaze-fix-copy_from_user.patch
queue-4.7/cris-buggered-copy_from_user-copy_to_user-clear_user.patch
queue-4.7/asm-generic-make-copy_from_user-zero-the-destination-properly.patch
queue-4.7/metag-copy_from_user-should-zero-the-destination-on-access_ok-failure.patch
queue-4.7/score-fix-__get_user-get_user.patch
queue-4.7/parisc-fix-copy_from_user.patch
queue-4.7/mips-copy_from_user-must-zero-the-destination-on-access_ok-failure.patch
queue-4.7/alpha-fix-copy_from_user.patch
queue-4.7/mn10300-failing-__get_user-and-get_user-should-zero.patch
queue-4.7/openrisc-fix-copy_from_user.patch
queue-4.7/avr32-fix-copy_from_user.patch
queue-4.7/score-fix-copy_from_user-and-friends.patch
queue-4.7/sh64-failing-__get_user-should-zero.patch
queue-4.7/arc-uaccess-get_user-to-zero-out-dest-in-cause-of-fault.patch
queue-4.7/hexagon-fix-strncpy_from_user-error-return.patch
queue-4.7/af_unix-split-u-readlock-into-two-iolock-and-bindlock.patch
queue-4.7/frv-fix-clear_user.patch
queue-4.7/fix-minor-infoleak-in-get_user_ex.patch
queue-4.7/asm-generic-make-get_user-clear-the-destination-on-errors.patch
queue-4.7/mn10300-copy_from_user-should-zero-on-access_ok-failure.patch
queue-4.7/s390-get_user-should-zero-on-failure.patch
queue-4.7/microblaze-fix-__get_user.patch
queue-4.7/blackfin-fix-copy_from_user.patch
queue-4.7/fix-iov_iter_fault_in_readable.patch
queue-4.7/nios2-fix-__get_user.patch
queue-4.7/sh-fix-copy_from_user.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-09-22 15:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 15:42 Patch "cris: buggered copy_from_user/copy_to_user/clear_user" has been added to the 4.7-stable tree gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.