blob: f5d9f08ee032f36a19cafa8a2d83f648d326fd97 [file] [log] [blame]
Al Virod5975802017-03-20 21:56:06 -04001#include <linux/uaccess.h>
2
3/* out-of-line parts */
4
5#ifndef INLINE_COPY_FROM_USER
6unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n)
7{
8 unsigned long res = n;
Al Viro9c5f6902017-06-29 21:39:54 -04009 might_fault();
10 if (likely(access_ok(VERIFY_READ, from, n))) {
11 kasan_check_write(to, n);
Al Virod5975802017-03-20 21:56:06 -040012 res = raw_copy_from_user(to, from, n);
Al Viro9c5f6902017-06-29 21:39:54 -040013 }
Al Virod5975802017-03-20 21:56:06 -040014 if (unlikely(res))
15 memset(to + (n - res), 0, res);
16 return res;
17}
18EXPORT_SYMBOL(_copy_from_user);
19#endif
20
21#ifndef INLINE_COPY_TO_USER
22unsigned long _copy_to_user(void *to, const void __user *from, unsigned long n)
23{
Al Viro9c5f6902017-06-29 21:39:54 -040024 might_fault();
25 if (likely(access_ok(VERIFY_WRITE, to, n))) {
26 kasan_check_read(from, n);
Al Virod5975802017-03-20 21:56:06 -040027 n = raw_copy_to_user(to, from, n);
Al Viro9c5f6902017-06-29 21:39:54 -040028 }
Al Virod5975802017-03-20 21:56:06 -040029 return n;
30}
31EXPORT_SYMBOL(_copy_to_user);
32#endif