Lines Matching +full:src +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
20 #define copy_from_kernel_nofault_loop(dst, src, len, type, err_label) \
22 __get_kernel_nofault(dst, src, type, err_label); \
23 kmsan_check_memory(src, sizeof(type)); \
25 src += sizeof(type); \
26 len -= sizeof(type); \
29 long copy_from_kernel_nofault(void *dst, const void *src, size_t size)
34 align = (unsigned long)dst | (unsigned long)src;
36 if (!copy_from_kernel_nofault_allowed(src, size))
37 return -ERANGE;
41 copy_from_kernel_nofault_loop(dst, src, size, u64, Efault);
43 copy_from_kernel_nofault_loop(dst, src, size, u32, Efault);
45 copy_from_kernel_nofault_loop(dst, src, size, u16, Efault);
46 copy_from_kernel_nofault_loop(dst, src, size, u8, Efault);
51 return -EFAULT;
55 #define copy_to_kernel_nofault_loop(dst, src, len, type, err_label) \
57 __put_kernel_nofault(dst, src, type, err_label); \
60 src += sizeof(type); \
61 len -= sizeof(type); \
64 long copy_to_kernel_nofault(void *dst, const void *src, size_t size)
69 align = (unsigned long)dst | (unsigned long)src;
73 copy_to_kernel_nofault_loop(dst, src, size, u64, Efault);
75 copy_to_kernel_nofault_loop(dst, src, size, u32, Efault);
77 copy_to_kernel_nofault_loop(dst, src, size, u16, Efault);
78 copy_to_kernel_nofault_loop(dst, src, size, u8, Efault);
83 return -EFAULT;
88 const void *src = unsafe_addr;
93 return -ERANGE;
97 __get_kernel_nofault(dst, src, u8, Efault);
99 src++;
100 } while (dst[-1] && src - unsafe_addr < count);
103 dst[-1] = '\0';
104 return src - unsafe_addr;
108 return -EFAULT;
112 * copy_from_user_nofault(): safely attempt to read from a user-space location
114 * @src: address to read from. This must be a user address.
117 * Safely read from user address @src to the buffer at @dst. If a kernel fault
118 * happens, handle that and return -EFAULT.
120 long copy_from_user_nofault(void *dst, const void __user *src, size_t size)
122 long ret = -EFAULT;
124 if (!__access_ok(src, size))
131 ret = __copy_from_user_inatomic(dst, src, size);
135 return -EFAULT;
141 * copy_to_user_nofault(): safely attempt to write to a user-space location
143 * @src: pointer to the data that shall be written
146 * Safely write to address @dst from the buffer at @src. If a kernel fault
147 * happens, handle that and return -EFAULT.
149 long copy_to_user_nofault(void __user *dst, const void *src, size_t size)
151 long ret = -EFAULT;
155 ret = __copy_to_user_inatomic(dst, src, size);
160 return -EFAULT;
166 * strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user
173 * Copies a NUL-terminated string from unsafe user address to kernel buffer.
177 * If access fails, returns -EFAULT (some data may have been copied
180 * If @count is smaller than the length of the string, copies @count-1 bytes,
197 dst[ret - 1] = '\0';
206 * strnlen_user_nofault: - Get the size of a user string INCLUDING final NUL.
210 * Get the size of a NUL-terminated string in user space without pagefault.