2017-03-21 04:56:06 +03:00
|
|
|
#include <linux/uaccess.h>
|
|
|
|
|
|
|
|
/* out-of-line parts */
|
|
|
|
|
|
|
|
#ifndef INLINE_COPY_FROM_USER
|
|
|
|
unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n)
|
|
|
|
{
|
|
|
|
unsigned long res = n;
|
2017-06-30 04:39:54 +03:00
|
|
|
might_fault();
|
|
|
|
if (likely(access_ok(VERIFY_READ, from, n))) {
|
|
|
|
kasan_check_write(to, n);
|
2017-03-21 04:56:06 +03:00
|
|
|
res = raw_copy_from_user(to, from, n);
|
2017-06-30 04:39:54 +03:00
|
|
|
}
|
2017-03-21 04:56:06 +03:00
|
|
|
if (unlikely(res))
|
|
|
|
memset(to + (n - res), 0, res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(_copy_from_user);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INLINE_COPY_TO_USER
|
|
|
|
unsigned long _copy_to_user(void *to, const void __user *from, unsigned long n)
|
|
|
|
{
|
2017-06-30 04:39:54 +03:00
|
|
|
might_fault();
|
|
|
|
if (likely(access_ok(VERIFY_WRITE, to, n))) {
|
|
|
|
kasan_check_read(from, n);
|
2017-03-21 04:56:06 +03:00
|
|
|
n = raw_copy_to_user(to, from, n);
|
2017-06-30 04:39:54 +03:00
|
|
|
}
|
2017-03-21 04:56:06 +03:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(_copy_to_user);
|
|
|
|
#endif
|