0001
0002
0003
0004
0005
0006
0007 #ifndef __UM_UACCESS_H
0008 #define __UM_UACCESS_H
0009
0010 #include <asm/elf.h>
0011 #include <asm/unaligned.h>
0012
0013 #define __under_task_size(addr, size) \
0014 (((unsigned long) (addr) < TASK_SIZE) && \
0015 (((unsigned long) (addr) + (size)) < TASK_SIZE))
0016
0017 #define __access_ok_vsyscall(addr, size) \
0018 (((unsigned long) (addr) >= FIXADDR_USER_START) && \
0019 ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
0020 ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
0021
0022 #define __addr_range_nowrap(addr, size) \
0023 ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
0024
0025 extern unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n);
0026 extern unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n);
0027 extern unsigned long __clear_user(void __user *mem, unsigned long len);
0028 static inline int __access_ok(const void __user *ptr, unsigned long size);
0029
0030
0031 #define __access_ok __access_ok
0032 #define __clear_user __clear_user
0033
0034 #define INLINE_COPY_FROM_USER
0035 #define INLINE_COPY_TO_USER
0036
0037 #include <asm-generic/uaccess.h>
0038
0039 static inline int __access_ok(const void __user *ptr, unsigned long size)
0040 {
0041 unsigned long addr = (unsigned long)ptr;
0042 return __addr_range_nowrap(addr, size) &&
0043 (__under_task_size(addr, size) ||
0044 __access_ok_vsyscall(addr, size));
0045 }
0046
0047
0048 #define __get_kernel_nofault(dst, src, type, err_label) \
0049 do { \
0050 *((type *)dst) = get_unaligned((type *)(src)); \
0051 if (0) \
0052 goto err_label; \
0053 } while (0)
0054
0055 #define __put_kernel_nofault(dst, src, type, err_label) \
0056 do { \
0057 put_unaligned(*((type *)src), (type *)(dst)); \
0058 if (0) \
0059 goto err_label; \
0060 } while (0)
0061
0062 #endif