Skip to content

Commit e33d1f6

Browse files
author
Al Viro
committed
nios2: copy_from_user() should zero the tail of destination
Cc: [email protected] Signed-off-by: Al Viro <[email protected]>
1 parent ae7cc57 commit e33d1f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/nios2/include/asm/uaccess.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ extern long __copy_to_user(void __user *to, const void *from, unsigned long n);
102102
static inline long copy_from_user(void *to, const void __user *from,
103103
unsigned long n)
104104
{
105-
if (!access_ok(VERIFY_READ, from, n))
106-
return n;
107-
return __copy_from_user(to, from, n);
105+
unsigned long res = n;
106+
if (access_ok(VERIFY_READ, from, n))
107+
res = __copy_from_user(to, from, n);
108+
if (unlikely(res))
109+
memset(to + (n - res), 0, res);
110+
return res;
108111
}
109112

110113
static inline long copy_to_user(void __user *to, const void *from,

0 commit comments

Comments
 (0)