Go to the documentation of this file.
15 #include <linux/errno.h>
16 #include <asm/processor.h>
20 #define VERIFY_WRITE 1
30 #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
32 #define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF)
33 #define USER_DS MAKE_MM_SEG(TASK_SIZE)
35 #define get_ds() (KERNEL_DS)
36 #define get_fs() (current_thread_info()->addr_limit)
37 #define set_fs(x) (current_thread_info()->addr_limit = (x))
39 #define segment_eq(a, b) ((a).seg == (b).seg)
41 #define __under_task_size(addr, size) \
42 (((unsigned long) (addr) < TASK_SIZE) && \
43 (((unsigned long) (addr) + (size)) < TASK_SIZE))
45 #define __access_ok_vsyscall(type, addr, size) \
46 ((type == VERIFY_READ) && \
47 ((unsigned long) (addr) >= FIXADDR_USER_START) && \
48 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
49 ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
51 #define __addr_range_nowrap(addr, size) \
52 ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
54 #define access_ok(type, addr, size) \
55 (__addr_range_nowrap(addr, size) && \
56 (__under_task_size(addr, size) || \
57 __access_ok_vsyscall(type, addr, size) || \
58 segment_eq(get_fs(), KERNEL_DS)))
122 #define __copy_from_user(to, from, n) copy_from_user(to, from, n)
124 #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
126 #define __copy_to_user_inatomic __copy_to_user
127 #define __copy_from_user_inatomic __copy_from_user
129 #define __get_user(x, ptr) \
131 const __typeof__(*(ptr)) __user *__private_ptr = (ptr); \
132 __typeof__(x) __private_val; \
133 int __private_ret = -EFAULT; \
134 (x) = (__typeof__(*(__private_ptr)))0; \
135 if (__copy_from_user((__force void *)&__private_val, (__private_ptr),\
136 sizeof(*(__private_ptr))) == 0) { \
137 (x) = (__typeof__(*(__private_ptr))) __private_val; \
143 #define get_user(x, ptr) \
145 const __typeof__((*(ptr))) __user *private_ptr = (ptr); \
146 (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
147 __get_user(x, private_ptr) : ((x) = (__typeof__(*ptr))0, -EFAULT)); \
150 #define __put_user(x, ptr) \
152 __typeof__(*(ptr)) __user *__private_ptr = ptr; \
153 __typeof__(*(__private_ptr)) __private_val; \
154 int __private_ret = -EFAULT; \
155 __private_val = (__typeof__(*(__private_ptr))) (x); \
156 if (__copy_to_user((__private_ptr), &__private_val, \
157 sizeof(*(__private_ptr))) == 0) { \
163 #define put_user(x, ptr) \
165 __typeof__(*(ptr)) __user *private_ptr = (ptr); \
166 (access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \
167 __put_user(x, private_ptr) : -EFAULT); \
170 #define strlen_user(str) strnlen_user(str, ~0U >> 1)