Commit f39be7f6 authored by Al Viro's avatar Al Viro Committed by Sasha Levin

parisc: fix copy_from_user()

[ Upstream commit aace880f ]

Cc: stable@vger.kernel.org
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent cc148fe4
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <asm-generic/uaccess-unaligned.h> #include <asm-generic/uaccess-unaligned.h>
#include <linux/bug.h> #include <linux/bug.h>
#include <linux/string.h>
#define VERIFY_READ 0 #define VERIFY_READ 0
#define VERIFY_WRITE 1 #define VERIFY_WRITE 1
...@@ -245,13 +246,14 @@ static inline unsigned long __must_check copy_from_user(void *to, ...@@ -245,13 +246,14 @@ static inline unsigned long __must_check copy_from_user(void *to,
unsigned long n) unsigned long n)
{ {
int sz = __compiletime_object_size(to); int sz = __compiletime_object_size(to);
int ret = -EFAULT; unsigned long ret = n;
if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n)) if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
ret = __copy_from_user(to, from, n); ret = __copy_from_user(to, from, n);
else else
copy_from_user_overflow(); copy_from_user_overflow();
if (unlikely(ret))
memset(to + (n - ret), 0, ret);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment