2017-11-01 15:07:57 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-03-20 21:56:06 -04: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-29 21:39:54 -04:00
|
|
|
might_fault();
|
2019-01-03 18:57:57 -08:00
|
|
|
if (likely(access_ok(from, n))) {
|
2017-06-29 21:39:54 -04:00
|
|
|
kasan_check_write(to, n);
|
2017-03-20 21:56:06 -04:00
|
|
|
res = raw_copy_from_user(to, from, n);
|
2017-06-29 21:39:54 -04:00
|
|
|
}
|
2017-03-20 21:56:06 -04:00
|
|
|
if (unlikely(res))
|
|
|
|
|
memset(to + (n - res), 0, res);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL(_copy_from_user);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef INLINE_COPY_TO_USER
|
2017-12-09 17:24:24 +01:00
|
|
|
unsigned long _copy_to_user(void __user *to, const void *from, unsigned long n)
|
2017-03-20 21:56:06 -04:00
|
|
|
{
|
2017-06-29 21:39:54 -04:00
|
|
|
might_fault();
|
2019-01-03 18:57:57 -08:00
|
|
|
if (likely(access_ok(to, n))) {
|
2017-06-29 21:39:54 -04:00
|
|
|
kasan_check_read(from, n);
|
2017-03-20 21:56:06 -04:00
|
|
|
n = raw_copy_to_user(to, from, n);
|
2017-06-29 21:39:54 -04:00
|
|
|
}
|
2017-03-20 21:56:06 -04:00
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL(_copy_to_user);
|
|
|
|
|
#endif
|