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/thread_info.h>
#include <linux/errno.h>
#include <asm/processor.h>
#include <asm/elf.h>

Go to the source code of this file.

Data Structures

struct  mm_segment_t
 
struct  exception_table_entry
 

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 __under_task_size(addr, size)
 
#define __access_ok_vsyscall(type, addr, size)
 
#define __addr_range_nowrap(addr, size)   ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
 
#define access_ok(type, addr, size)
 
#define __copy_from_user(to, from, n)   copy_from_user(to, from, n)
 
#define __copy_to_user(to, from, n)   copy_to_user(to, from, n)
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 
#define __get_user(x, ptr)
 
#define get_user(x, ptr)
 
#define __put_user(x, ptr)
 
#define put_user(x, ptr)
 
#define strlen_user(str)   strnlen_user(str, ~0U >> 1)
 

Functions

int copy_from_user (void *to, const void __user *from, int n)
 
int copy_to_user (void __user *to, const void *from, int n)
 
int strncpy_from_user (char *dst, const char __user *src, int count)
 
int __clear_user (void __user *mem, int len)
 
int clear_user (void __user *mem, int len)
 
int strnlen_user (const void __user *str, int len)
 

Macro Definition Documentation

#define __access_ok_vsyscall (   type,
  addr,
  size 
)
Value:
((type == VERIFY_READ) && \
((unsigned long) (addr) >= FIXADDR_USER_START) && \
((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
((unsigned long) (addr) + (size) >= (unsigned long)(addr)))

Definition at line 45 of file uaccess.h.

#define __addr_range_nowrap (   addr,
  size 
)    ((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))

Definition at line 51 of file uaccess.h.

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

Definition at line 122 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 127 of file uaccess.h.

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

Definition at line 124 of file uaccess.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 126 of file uaccess.h.

#define __get_user (   x,
  ptr 
)
Value:
({ \
const __typeof__(*(ptr)) __user *__private_ptr = (ptr); \
__typeof__(x) __private_val; \
int __private_ret = -EFAULT; \
(x) = (__typeof__(*(__private_ptr)))0; \
if (__copy_from_user((__force void *)&__private_val, (__private_ptr),\
sizeof(*(__private_ptr))) == 0) { \
(x) = (__typeof__(*(__private_ptr))) __private_val; \
__private_ret = 0; \
} \
__private_ret; \
})

Definition at line 129 of file uaccess.h.

#define __put_user (   x,
  ptr 
)
Value:
({ \
__typeof__(*(ptr)) __user *__private_ptr = ptr; \
__typeof__(*(__private_ptr)) __private_val; \
int __private_ret = -EFAULT; \
__private_val = (__typeof__(*(__private_ptr))) (x); \
if (__copy_to_user((__private_ptr), &__private_val, \
sizeof(*(__private_ptr))) == 0) { \
__private_ret = 0; \
} \
__private_ret; \
})

Definition at line 150 of file uaccess.h.

#define __under_task_size (   addr,
  size 
)
Value:
(((unsigned long) (addr) < TASK_SIZE) && \
(((unsigned long) (addr) + (size)) < TASK_SIZE))

Definition at line 41 of file uaccess.h.

#define access_ok (   type,
  addr,
  size 
)
Value:
__access_ok_vsyscall(type, addr, size) || \
segment_eq(get_fs(), KERNEL_DS)))

Definition at line 54 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 35 of file uaccess.h.

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

Definition at line 36 of file uaccess.h.

#define get_user (   x,
  ptr 
)
Value:
({ \
const __typeof__((*(ptr))) __user *private_ptr = (ptr); \
(access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
__get_user(x, private_ptr) : ((x) = (__typeof__(*ptr))0, -EFAULT)); \
})

Definition at line 143 of file uaccess.h.

#define KERNEL_DS   MAKE_MM_SEG(0xFFFFFFFF)

Definition at line 32 of file uaccess.h.

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

Definition at line 30 of file uaccess.h.

#define put_user (   x,
  ptr 
)
Value:
({ \
__typeof__(*(ptr)) __user *private_ptr = (ptr); \
(access_ok(VERIFY_WRITE, private_ptr, sizeof(*private_ptr)) ? \
__put_user(x, private_ptr) : -EFAULT); \
})

Definition at line 163 of file uaccess.h.

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

Definition at line 39 of file uaccess.h.

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

Definition at line 37 of file uaccess.h.

#define strlen_user (   str)    strnlen_user(str, ~0U >> 1)

Definition at line 170 of file uaccess.h.

#define USER_DS   MAKE_MM_SEG(TASK_SIZE)

Definition at line 33 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 19 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 20 of file uaccess.h.

Function Documentation

int __clear_user ( void __user mem,
int  len 
)

Definition at line 218 of file uaccess.c.

int clear_user ( void __user mem,
int  len 
)

Definition at line 223 of file uaccess.c.

int copy_from_user ( void to,
const void __user from,
int  n 
)

Definition at line 142 of file uaccess.c.

int copy_to_user ( void __user to,
const void from,
int  n 
)

Definition at line 164 of file uaccess.c.

int strncpy_from_user ( char dst,
const char __user src,
int  count 
)

Definition at line 191 of file uaccess.c.

int strnlen_user ( const void __user str,
int  len 
)

Definition at line 247 of file uaccess.c.