Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
uaccess.h File Reference
#include <linux/sched.h>
#include <linux/errno.h>
#include <asm/processor.h>
#include <asm/page.h>
#include <arch/uaccess.h>

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 
struct  __large_struct
 

Macros

#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define MAKE_MM_SEG(s)   ((mm_segment_t) { (s) })
 
#define KERNEL_DS   MAKE_MM_SEG(0xFFFFFFFF)
 
#define USER_DS   MAKE_MM_SEG(TASK_SIZE)
 
#define get_ds()   (KERNEL_DS)
 
#define get_fs()   (current_thread_info()->addr_limit)
 
#define set_fs(x)   (current_thread_info()->addr_limit = (x))
 
#define segment_eq(a, b)   ((a).seg == (b).seg)
 
#define __kernel_ok   (segment_eq(get_fs(), KERNEL_DS))
 
#define __user_ok(addr, size)   (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size)))
 
#define __access_ok(addr, size)   (__kernel_ok || __user_ok((addr),(size)))
 
#define access_ok(type, addr, size)   __access_ok((unsigned long)(addr),(size))
 
#define get_user(x, ptr)   __get_user_check((x),(ptr),sizeof(*(ptr)))
 
#define put_user(x, ptr)   __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
#define __get_user(x, ptr)   __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
 
#define __put_user(x, ptr)   __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
#define __put_user_size(x, ptr, size, retval)
 
#define __get_user_size(x, ptr, size, retval)
 
#define __put_user_nocheck(x, ptr, size)
 
#define __put_user_check(x, ptr, size)
 
#define __m(x)   (*(struct __large_struct *)(x))
 
#define __get_user_nocheck(x, ptr, size)
 
#define __get_user_check(x, ptr, size)
 
#define clear_user(to, n)
 
#define copy_from_user(to, from, n)
 
#define copy_to_user(to, from, n)
 
#define __copy_to_user(to, from, n)   __generic_copy_to_user_nocheck((to),(from),(n))
 
#define __copy_from_user(to, from, n)   __generic_copy_from_user_nocheck((to),(from),(n))
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 
#define __clear_user(to, n)   __generic_clear_user_nocheck((to),(n))
 
#define strlen_user(str)   strnlen_user((str), 0x7ffffffe)
 

Functions

long __put_user_bad (void)
 
long __get_user_bad (void)
 
unsigned long __copy_user (void __user *to, const void *from, unsigned long n)
 
unsigned long __copy_user_zeroing (void *to, const void __user *from, unsigned long n)
 
unsigned long __do_clear_user (void __user *to, unsigned long n)
 

Macro Definition Documentation

#define __access_ok (   addr,
  size 
)    (__kernel_ok || __user_ok((addr),(size)))

Definition at line 54 of file uaccess.h.

#define __clear_user (   to,
  n 
)    __generic_clear_user_nocheck((to),(n))

Definition at line 398 of file uaccess.h.

#define __copy_from_user (   to,
  from,
  n 
)    __generic_copy_from_user_nocheck((to),(from),(n))

Definition at line 395 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 397 of file uaccess.h.

#define __copy_to_user (   to,
  from,
  n 
)    __generic_copy_to_user_nocheck((to),(from),(n))

Definition at line 394 of file uaccess.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 396 of file uaccess.h.

#define __get_user (   x,
  ptr 
)    __get_user_nocheck((x),(ptr),sizeof(*(ptr)))

Definition at line 100 of file uaccess.h.

#define __get_user_check (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err = -EFAULT, __gu_val = 0; \
const __typeof__(*(ptr)) *__gu_addr = (ptr); \
if (access_ok(VERIFY_READ,__gu_addr,size)) \
__get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \
})

Definition at line 160 of file uaccess.h.

#define __get_user_nocheck (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err, __gu_val; \
__get_user_size(__gu_val,(ptr),(size),__gu_err); \
(x) = (__typeof__(*(ptr)))__gu_val; \
__gu_err; \
})

Definition at line 152 of file uaccess.h.

#define __get_user_size (   x,
  ptr,
  size,
  retval 
)
Value:
do { \
retval = 0; \
switch (size) { \
case 1: __get_user_asm(x,ptr,retval,"move.b"); break; \
case 2: __get_user_asm(x,ptr,retval,"move.w"); break; \
case 4: __get_user_asm(x,ptr,retval,"move.d"); break; \
case 8: __get_user_asm_64(x,ptr,retval); break; \
default: (x) = __get_user_bad(); \
} \
} while (0)

Definition at line 119 of file uaccess.h.

#define __kernel_ok   (segment_eq(get_fs(), KERNEL_DS))

Definition at line 52 of file uaccess.h.

#define __m (   x)    (*(struct __large_struct *)(x))

Definition at line 148 of file uaccess.h.

#define __put_user (   x,
  ptr 
)    __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))

Definition at line 102 of file uaccess.h.

#define __put_user_check (   x,
  ptr,
  size 
)
Value:
({ \
long __pu_err = -EFAULT; \
__typeof__(*(ptr)) *__pu_addr = (ptr); \
if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
__put_user_size((x),__pu_addr,(size),__pu_err); \
__pu_err; \
})

Definition at line 138 of file uaccess.h.

#define __put_user_nocheck (   x,
  ptr,
  size 
)
Value:
({ \
long __pu_err; \
__put_user_size((x),(ptr),(size),__pu_err); \
__pu_err; \
})

Definition at line 131 of file uaccess.h.

#define __put_user_size (   x,
  ptr,
  size,
  retval 
)
Value:
do { \
retval = 0; \
switch (size) { \
case 1: __put_user_asm(x,ptr,retval,"move.b"); break; \
case 2: __put_user_asm(x,ptr,retval,"move.w"); break; \
case 4: __put_user_asm(x,ptr,retval,"move.d"); break; \
case 8: __put_user_asm_64(x,ptr,retval); break; \
default: __put_user_bad(); \
} \
} while (0)

Definition at line 107 of file uaccess.h.

#define __user_ok (   addr,
  size 
)    (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size)))

Definition at line 53 of file uaccess.h.

#define access_ok (   type,
  addr,
  size 
)    __access_ok((unsigned long)(addr),(size))

Definition at line 55 of file uaccess.h.

#define clear_user (   to,
  n 
)
Value:
(__builtin_constant_p(n) ? \
__constant_clear_user(to, n) : \
__generic_clear_user(to, n))

Definition at line 353 of file uaccess.h.

#define copy_from_user (   to,
  from,
  n 
)
Value:
(__builtin_constant_p(n) ? \
__constant_copy_from_user(to, from, n) : \
__generic_copy_from_user(to, from, n))

Definition at line 358 of file uaccess.h.

#define copy_to_user (   to,
  from,
  n 
)
Value:
(__builtin_constant_p(n) ? \
__constant_copy_to_user(to, from, n) : \
__generic_copy_to_user(to, from, n))

Definition at line 363 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 46 of file uaccess.h.

#define get_fs (   void)    (current_thread_info()->addr_limit)

Definition at line 47 of file uaccess.h.

#define get_user (   x,
  ptr 
)    __get_user_check((x),(ptr),sizeof(*(ptr)))

Definition at line 95 of file uaccess.h.

#define KERNEL_DS   MAKE_MM_SEG(0xFFFFFFFF)

Definition at line 43 of file uaccess.h.

#define MAKE_MM_SEG (   s)    ((mm_segment_t) { (s) })

Definition at line 35 of file uaccess.h.

#define put_user (   x,
  ptr 
)    __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))

Definition at line 97 of file uaccess.h.

#define segment_eq (   a,
  b 
)    ((a).seg == (b).seg)

Definition at line 50 of file uaccess.h.

#define set_fs (   x)    (current_thread_info()->addr_limit = (x))

Definition at line 48 of file uaccess.h.

#define strlen_user (   str)    strnlen_user((str), 0x7ffffffe)

Definition at line 400 of file uaccess.h.

#define USER_DS   MAKE_MM_SEG(TASK_SIZE)

Definition at line 44 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 24 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 25 of file uaccess.h.

Function Documentation

unsigned long __copy_user ( void __user to,
const void from,
unsigned long  n 
)

Definition at line 34 of file usercopy.c.

unsigned long __copy_user_zeroing ( void to,
const void __user from,
unsigned long  n 
)

Definition at line 196 of file usercopy.c.

unsigned long __do_clear_user ( void __user to,
unsigned long  n 
)

Definition at line 376 of file usercopy.c.

long __get_user_bad ( void  )
long __put_user_bad ( void  )