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/compiler.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/page-flags.h>
#include <linux/mm.h>
#include <asm/intrinsics.h>
#include <asm/pgtable.h>
#include <asm/io.h>

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 

Macros

#define KERNEL_DS   ((mm_segment_t) { ~0UL }) /* cf. access_ok() */
 
#define USER_DS   ((mm_segment_t) { TASK_SIZE-1 }) /* cf. access_ok() */
 
#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#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 __access_ok(addr, size, segment)
 
#define access_ok(type, addr, size)   __access_ok((addr), (size), get_fs())
 
#define put_user(x, ptr)   __put_user_check((__typeof__(*(ptr))) (x), (ptr), sizeof(*(ptr)), get_fs())
 
#define get_user(x, ptr)   __get_user_check((x), (ptr), sizeof(*(ptr)), get_fs())
 
#define __put_user(x, ptr)   __put_user_nocheck((__typeof__(*(ptr))) (x), (ptr), sizeof(*(ptr)))
 
#define __get_user(x, ptr)   __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
 
#define __put_user_unaligned(x, ptr)
 
#define __get_user_unaligned(x, ptr)
 
#define RELOC_TYPE   2 /* ip-rel */
 
#define __get_user_size(val, addr, n, err)
 
#define __put_user_size(val, addr, n, err)
 
#define __do_get_user(check, x, ptr, size, segment)
 
#define __get_user_nocheck(x, ptr, size)   __do_get_user(0, x, ptr, size, KERNEL_DS)
 
#define __get_user_check(x, ptr, size, segment)   __do_get_user(1, x, ptr, size, segment)
 
#define __do_put_user(check, x, ptr, size, segment)
 
#define __put_user_nocheck(x, ptr, size)   __do_put_user(0, x, ptr, size, KERNEL_DS)
 
#define __put_user_check(x, ptr, size, segment)   __do_put_user(1, x, ptr, size, segment)
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 
#define copy_to_user(to, from, n)
 
#define copy_from_user(to, from, n)
 
#define __copy_in_user(to, from, size)   __copy_user((to), (from), (size))
 
#define __clear_user(to, n)   __do_clear_user(to, n)
 
#define clear_user(to, n)
 
#define strncpy_from_user(to, from, n)
 
#define strlen_user(str)
 
#define strnlen_user(str, len)
 
#define ARCH_HAS_SORT_EXTABLE
 
#define ARCH_HAS_SEARCH_EXTABLE
 
#define ARCH_HAS_TRANSLATE_MEM_PTR   1
 

Functions

long __put_user_unaligned_unknown (void)
 
long __get_user_unaligned_unknown (void)
 
void __get_user_unknown (void)
 
void __put_user_unknown (void)
 
unsigned long __must_check __copy_user (void __user *to, const void __user *from, unsigned long count)
 
unsigned long __do_clear_user (void __user *, unsigned long)
 
long __must_check __strncpy_from_user (char *to, const char __user *from, long to_len)
 
unsigned long __strlen_user (const char __user *)
 
unsigned long __strnlen_user (const char __user *, long)
 
void ia64_handle_exception (struct pt_regs *regs, const struct exception_table_entry *e)
 
struct exception_table_entrysearch_exception_tables (unsigned long addr)
 

Macro Definition Documentation

#define __access_ok (   addr,
  size,
  segment 
)
Value:
({ \
__chk_user_ptr(addr); \
(likely((unsigned long) (addr) <= (segment).seg) \
&& ((segment).seg == KERNEL_DS.seg \
|| likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT))); \
})

Definition at line 66 of file uaccess.h.

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

Definition at line 289 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 253 of file uaccess.h.

#define __copy_in_user (   to,
  from,
  size 
)    __copy_user((to), (from), (size))

Definition at line 277 of file uaccess.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 252 of file uaccess.h.

#define __do_get_user (   check,
  x,
  ptr,
  size,
  segment 
)
Value:
({ \
const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \
__typeof__ (size) __gu_size = (size); \
long __gu_err = -EFAULT; \
unsigned long __gu_val = 0; \
if (!check || __access_ok(__gu_ptr, size, segment)) \
switch (__gu_size) { \
case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \
case 2: __get_user_size(__gu_val, __gu_ptr, 2, __gu_err); break; \
case 4: __get_user_size(__gu_val, __gu_ptr, 4, __gu_err); break; \
case 8: __get_user_size(__gu_val, __gu_ptr, 8, __gu_err); break; \
default: __get_user_unknown(); break; \
} \
(x) = (__typeof__(*(__gu_ptr))) __gu_val; \
__gu_err; \
})

Definition at line 186 of file uaccess.h.

#define __do_put_user (   check,
  x,
  ptr,
  size,
  segment 
)
Value:
({ \
__typeof__ (x) __pu_x = (x); \
__typeof__ (*(ptr)) __user *__pu_ptr = (ptr); \
__typeof__ (size) __pu_size = (size); \
long __pu_err = -EFAULT; \
\
if (!check || __access_ok(__pu_ptr, __pu_size, segment)) \
switch (__pu_size) { \
case 1: __put_user_size(__pu_x, __pu_ptr, 1, __pu_err); break; \
case 2: __put_user_size(__pu_x, __pu_ptr, 2, __pu_err); break; \
case 4: __put_user_size(__pu_x, __pu_ptr, 4, __pu_err); break; \
case 8: __put_user_size(__pu_x, __pu_ptr, 8, __pu_err); break; \
default: __put_user_unknown(); break; \
} \
__pu_err; \
})

Definition at line 213 of file uaccess.h.

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

Definition at line 92 of file uaccess.h.

#define __get_user_check (   x,
  ptr,
  size,
  segment 
)    __do_get_user(1, x, ptr, size, segment)

Definition at line 205 of file uaccess.h.

#define __get_user_nocheck (   x,
  ptr,
  size 
)    __do_get_user(0, x, ptr, size, KERNEL_DS)

Definition at line 204 of file uaccess.h.

#define __get_user_size (   val,
  addr,
  n,
  err 
)
Value:
do { \
__ld_user("__ex_table", (unsigned long) addr, n, RELOC_TYPE); \
} while (0)

Definition at line 166 of file uaccess.h.

#define __get_user_unaligned (   x,
  ptr 
)
Value:
({ \
long __ret; \
switch (sizeof(*(ptr))) { \
case 1: __ret = __get_user((x), (ptr)); break; \
case 2: __ret = (__get_user((x), (u8 __user *)(ptr))) \
| (__get_user((x) >> 8, ((u8 __user *)(ptr) + 1))); break; \
case 4: __ret = (__get_user((x), (u16 __user *)(ptr))) \
| (__get_user((x) >> 16, ((u16 __user *)(ptr) + 1))); break; \
case 8: __ret = (__get_user((x), (u32 __user *)(ptr))) \
| (__get_user((x) >> 32, ((u32 __user *)(ptr) + 1))); break; \
default: __ret = __get_user_unaligned_unknown(); \
} \
__ret; \
})

Definition at line 114 of file uaccess.h.

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

Definition at line 91 of file uaccess.h.

#define __put_user_check (   x,
  ptr,
  size,
  segment 
)    __do_put_user(1, x, ptr, size, segment)

Definition at line 232 of file uaccess.h.

#define __put_user_nocheck (   x,
  ptr,
  size 
)    __do_put_user(0, x, ptr, size, KERNEL_DS)

Definition at line 231 of file uaccess.h.

#define __put_user_size (   val,
  addr,
  n,
  err 
)
Value:
do { \
__st_user("__ex_table", (unsigned long) addr, n, RELOC_TYPE, (unsigned long) (val)); \
} while (0)

Definition at line 172 of file uaccess.h.

#define __put_user_unaligned (   x,
  ptr 
)
Value:
({ \
long __ret; \
switch (sizeof(*(ptr))) { \
case 1: __ret = __put_user((x), (ptr)); break; \
case 2: __ret = (__put_user((x), (u8 __user *)(ptr))) \
| (__put_user((x) >> 8, ((u8 __user *)(ptr) + 1))); break; \
case 4: __ret = (__put_user((x), (u16 __user *)(ptr))) \
| (__put_user((x) >> 16, ((u16 __user *)(ptr) + 1))); break; \
case 8: __ret = (__put_user((x), (u32 __user *)(ptr))) \
| (__put_user((x) >> 32, ((u32 __user *)(ptr) + 1))); break; \
default: __ret = __put_user_unaligned_unknown(); \
} \
__ret; \
})

Definition at line 96 of file uaccess.h.

#define access_ok (   type,
  addr,
  size 
)    __access_ok((addr), (size), get_fs())

Definition at line 73 of file uaccess.h.

#define ARCH_HAS_SEARCH_EXTABLE

Definition at line 345 of file uaccess.h.

#define ARCH_HAS_SORT_EXTABLE

Definition at line 344 of file uaccess.h.

#define ARCH_HAS_TRANSLATE_MEM_PTR   1

Definition at line 367 of file uaccess.h.

#define clear_user (   to,
  n 
)
Value:
({ \
unsigned long __cu_len = (n); \
if (__access_ok(to, __cu_len, get_fs())) \
__cu_len = __do_clear_user(to, __cu_len); \
__cu_len; \
})

Definition at line 291 of file uaccess.h.

#define copy_from_user (   to,
  from,
  n 
)
Value:
({ \
void *__cu_to = (to); \
const void __user *__cu_from = (from); \
long __cu_len = (n); \
__chk_user_ptr(__cu_from); \
if (__access_ok(__cu_from, __cu_len, get_fs())) \
__cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
__cu_len; \
})

Definition at line 265 of file uaccess.h.

#define copy_to_user (   to,
  from,
  n 
)
Value:
({ \
void __user *__cu_to = (to); \
const void *__cu_from = (from); \
long __cu_len = (n); \
if (__access_ok(__cu_to, __cu_len, get_fs())) \
__cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
__cu_len; \
})

Definition at line 254 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 54 of file uaccess.h.

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

Definition at line 55 of file uaccess.h.

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

Definition at line 84 of file uaccess.h.

#define KERNEL_DS   ((mm_segment_t) { ~0UL }) /* cf. access_ok() */

Definition at line 48 of file uaccess.h.

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

Definition at line 83 of file uaccess.h.

#define RELOC_TYPE   2 /* ip-rel */

Definition at line 165 of file uaccess.h.

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

Definition at line 58 of file uaccess.h.

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

Definition at line 56 of file uaccess.h.

#define strlen_user (   str)
Value:
({ \
const char __user *__su_str = (str); \
unsigned long __su_ret = 0; \
if (__access_ok(__su_str, 0, get_fs())) \
__su_ret = __strlen_user(__su_str); \
__su_ret; \
})

Definition at line 318 of file uaccess.h.

#define strncpy_from_user (   to,
  from,
  n 
)
Value:
({ \
const char __user * __sfu_from = (from); \
long __sfu_ret = -EFAULT; \
if (__access_ok(__sfu_from, 0, get_fs())) \
__sfu_ret = __strncpy_from_user((to), __sfu_from, (n)); \
__sfu_ret; \
})

Definition at line 306 of file uaccess.h.

#define strnlen_user (   str,
  len 
)
Value:
({ \
const char __user *__su_str = (str); \
unsigned long __su_ret = 0; \
if (__access_ok(__su_str, 0, get_fs())) \
__su_ret = __strnlen_user(__su_str, len); \
__su_ret; \
})

Definition at line 334 of file uaccess.h.

#define USER_DS   ((mm_segment_t) { TASK_SIZE-1 }) /* cf. access_ok() */

Definition at line 49 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 51 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 52 of file uaccess.h.

Function Documentation

unsigned long __must_check __copy_user ( void __user to,
const void __user from,
unsigned long  count 
)
unsigned long __do_clear_user ( void __user ,
unsigned  long 
)

Definition at line 376 of file usercopy.c.

long __get_user_unaligned_unknown ( void  )
void __get_user_unknown ( void  )
long __put_user_unaligned_unknown ( void  )
void __put_user_unknown ( void  )
unsigned long __strlen_user ( const char __user )
long __must_check __strncpy_from_user ( char to,
const char __user from,
long  to_len 
)

Definition at line 113 of file usercopy.c.

unsigned long __strnlen_user ( const char __user ,
long   
)
void ia64_handle_exception ( struct pt_regs regs,
const struct exception_table_entry e 
)

Definition at line 106 of file extable.c.

struct exception_table_entry* search_exception_tables ( unsigned long  addr)
read

Definition at line 51 of file extable.c.