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) \ argument
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) in copy_from_kernel_nofault() argument
34 align = (unsigned long)dst | (unsigned long)src; in copy_from_kernel_nofault()
36 if (!copy_from_kernel_nofault_allowed(src, size)) in copy_from_kernel_nofault()
37 return -ERANGE; in copy_from_kernel_nofault()
41 copy_from_kernel_nofault_loop(dst, src, size, u64, Efault); in copy_from_kernel_nofault()
43 copy_from_kernel_nofault_loop(dst, src, size, u32, Efault); in copy_from_kernel_nofault()
45 copy_from_kernel_nofault_loop(dst, src, size, u16, Efault); in copy_from_kernel_nofault()
46 copy_from_kernel_nofault_loop(dst, src, size, u8, Efault); in copy_from_kernel_nofault()
51 return -EFAULT; in copy_from_kernel_nofault()
55 #define copy_to_kernel_nofault_loop(dst, src, len, type, err_label) \ argument
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) in copy_to_kernel_nofault() argument
69 align = (unsigned long)dst | (unsigned long)src; in copy_to_kernel_nofault()
73 copy_to_kernel_nofault_loop(dst, src, size, u64, Efault); in copy_to_kernel_nofault()
75 copy_to_kernel_nofault_loop(dst, src, size, u32, Efault); in copy_to_kernel_nofault()
77 copy_to_kernel_nofault_loop(dst, src, size, u16, Efault); in copy_to_kernel_nofault()
78 copy_to_kernel_nofault_loop(dst, src, size, u8, Efault); in copy_to_kernel_nofault()
83 return -EFAULT; in copy_to_kernel_nofault()
89 const void *src = unsafe_addr; in strncpy_from_kernel_nofault() local
94 return -ERANGE; in strncpy_from_kernel_nofault()
98 __get_kernel_nofault(dst, src, u8, Efault); in strncpy_from_kernel_nofault()
100 src++; in strncpy_from_kernel_nofault()
101 } while (dst[-1] && src - unsafe_addr < count); in strncpy_from_kernel_nofault()
104 dst[-1] = '\0'; in strncpy_from_kernel_nofault()
105 return src - unsafe_addr; in strncpy_from_kernel_nofault()
109 return -EFAULT; in strncpy_from_kernel_nofault()
113 * copy_from_user_nofault(): safely attempt to read from a user-space location
115 * @src: address to read from. This must be a user address.
118 * Safely read from user address @src to the buffer at @dst. If a kernel fault
119 * happens, handle that and return -EFAULT.
121 long copy_from_user_nofault(void *dst, const void __user *src, size_t size) in copy_from_user_nofault() argument
123 long ret = -EFAULT; in copy_from_user_nofault()
125 if (!__access_ok(src, size)) in copy_from_user_nofault()
132 ret = __copy_from_user_inatomic(dst, src, size); in copy_from_user_nofault()
136 return -EFAULT; in copy_from_user_nofault()
142 * copy_to_user_nofault(): safely attempt to write to a user-space location
144 * @src: pointer to the data that shall be written
147 * Safely write to address @dst from the buffer at @src. If a kernel fault
148 * happens, handle that and return -EFAULT.
150 long copy_to_user_nofault(void __user *dst, const void *src, size_t size) in copy_to_user_nofault() argument
152 long ret = -EFAULT; in copy_to_user_nofault()
156 ret = __copy_to_user_inatomic(dst, src, size); in copy_to_user_nofault()
161 return -EFAULT; in copy_to_user_nofault()
167 * strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user
174 * Copies a NUL-terminated string from unsafe user address to kernel buffer.
178 * If access fails, returns -EFAULT (some data may have been copied
181 * If @count is smaller than the length of the string, copies @count-1 bytes,
198 dst[ret - 1] = '\0'; in strncpy_from_user_nofault()
207 * strnlen_user_nofault: - Get the size of a user string INCLUDING final NUL.
211 * Get the size of a NUL-terminated string in user space without pagefault.