1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/compiler.h>
7 extern void *__user_addr_min
, *__user_addr_max
;
9 static inline void __chk_user_ptr(const volatile void *p
, size_t size
)
11 assert(p
>= __user_addr_min
&& p
+ size
<= __user_addr_max
);
14 #define put_user(x, ptr) \
16 typeof(ptr) __pu_ptr = (ptr); \
17 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
18 WRITE_ONCE(*(__pu_ptr), x); \
22 #define get_user(x, ptr) \
24 typeof(ptr) __pu_ptr = (ptr); \
25 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
26 x = READ_ONCE(*(__pu_ptr)); \
30 static void volatile_memcpy(volatile char *to
, const volatile char *from
,
37 static inline int copy_from_user(void *to
, const void __user
volatile *from
,
40 __chk_user_ptr(from
, n
);
41 volatile_memcpy(to
, from
, n
);
45 static inline int copy_to_user(void __user
volatile *to
, const void *from
,
48 __chk_user_ptr(to
, n
);
49 volatile_memcpy(to
, from
, n
);
52 #endif /* UACCESS_H */