1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/uaccess.h>
3 #include <linux/nospec.h>
5 /* out-of-line parts */
7 #ifndef INLINE_COPY_FROM_USER
8 unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n)
10 unsigned long res = n;
12 if (likely(access_ok(VERIFY_READ, from, n))) {
14 * Ensure that bad access_ok() speculation will not
15 * lead to nasty side effects *after* the copy is
19 kasan_check_write(to, n);
20 res = raw_copy_from_user(to, from, n);
23 memset(to + (n - res), 0, res);
26 EXPORT_SYMBOL(_copy_from_user);
29 #ifndef INLINE_COPY_TO_USER
30 unsigned long _copy_to_user(void __user *to, const void *from, unsigned long n)
33 if (likely(access_ok(VERIFY_WRITE, to, n))) {
34 kasan_check_read(from, n);
35 n = raw_copy_to_user(to, from, n);
39 EXPORT_SYMBOL(_copy_to_user);