summaryrefslogtreecommitdiffstats
path: root/arch/frv
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-08-18 20:54:02 -0400
committerBen Hutchings <ben@decadent.org.uk>2016-11-20 01:17:27 +0000
commitbfc7cbee2d22075ded01b855517cd2b7dc5784fb (patch)
treeec290ff7de5bb0283c3bffcb8a5a429a519422bf /arch/frv
parent63937b3bf2bdf65978703b4d45f54396a0b77ed9 (diff)
downloadlinux-stable-bfc7cbee2d22075ded01b855517cd2b7dc5784fb.tar.gz
linux-stable-bfc7cbee2d22075ded01b855517cd2b7dc5784fb.tar.bz2
linux-stable-bfc7cbee2d22075ded01b855517cd2b7dc5784fb.zip
frv: fix clear_user()
commit 3b8767a8f00cc6538ba6b1cf0f88502e2fd2eb90 upstream. It should check access_ok(). Otherwise a bunch of places turn into trivially exploitable rootholes. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch/frv')
-rw-r--r--arch/frv/include/asm/uaccess.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/frv/include/asm/uaccess.h b/arch/frv/include/asm/uaccess.h
index 3ac9a59d65d4..87d9e34c5df8 100644
--- a/arch/frv/include/asm/uaccess.h
+++ b/arch/frv/include/asm/uaccess.h
@@ -263,19 +263,25 @@ do { \
extern long __memset_user(void *dst, unsigned long count);
extern long __memcpy_user(void *dst, const void *src, unsigned long count);
-#define clear_user(dst,count) __memset_user(____force(dst), (count))
+#define __clear_user(dst,count) __memset_user(____force(dst), (count))
#define __copy_from_user_inatomic(to, from, n) __memcpy_user((to), ____force(from), (n))
#define __copy_to_user_inatomic(to, from, n) __memcpy_user(____force(to), (from), (n))
#else
-#define clear_user(dst,count) (memset(____force(dst), 0, (count)), 0)
+#define __clear_user(dst,count) (memset(____force(dst), 0, (count)), 0)
#define __copy_from_user_inatomic(to, from, n) (memcpy((to), ____force(from), (n)), 0)
#define __copy_to_user_inatomic(to, from, n) (memcpy(____force(to), (from), (n)), 0)
#endif
-#define __clear_user clear_user
+static inline unsigned long __must_check
+clear_user(void __user *to, unsigned long n)
+{
+ if (likely(__access_ok(to, n)))
+ n = __clear_user(to, n);
+ return n;
+}
static inline unsigned long __must_check
__copy_to_user(void __user *to, const void *from, unsigned long n)