Skip to content

Commit a5e541f

Browse files
author
Al Viro
committed
ia64: copy_from_user() should zero the destination on access_ok() failure
Cc: [email protected] Signed-off-by: Al Viro <[email protected]>
1 parent f35c1e0 commit a5e541f

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

arch/ia64/include/asm/uaccess.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,17 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
272272
__cu_len; \
273273
})
274274

275-
#define copy_from_user(to, from, n) \
276-
({ \
277-
void *__cu_to = (to); \
278-
const void __user *__cu_from = (from); \
279-
long __cu_len = (n); \
280-
\
281-
__chk_user_ptr(__cu_from); \
282-
if (__access_ok(__cu_from, __cu_len, get_fs())) { \
283-
if (!__builtin_constant_p(n)) \
284-
check_object_size(__cu_to, __cu_len, false); \
285-
__cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
286-
} \
287-
__cu_len; \
288-
})
275+
static inline unsigned long
276+
copy_from_user(void *to, const void __user *from, unsigned long n)
277+
{
278+
if (!__builtin_constant_p(n))
279+
check_object_size(to, n, false);
280+
if (likely(__access_ok(from, n, get_fs())))
281+
n = __copy_user((__force void __user *) to, from, n);
282+
else
283+
memset(to, 0, n);
284+
return n;
285+
}
289286

290287
#define __copy_in_user(to, from, size) __copy_user((to), (from), (size))
291288

0 commit comments

Comments
 (0)