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/errno.h>
#include <linux/sched.h>
#include <asm/segment.h>
#include <asm/uaccess_64.h>

Go to the source code of this file.

Data Structures

struct  __large_struct
 
struct  exception_table_entry
 
struct  mem_access
 

Macros

#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define __addr_ok(addr)   ((unsigned long __force)(addr) < current_thread_info()->addr_limit.seg)
 
#define __access_ok(addr, size)   (__addr_ok((addr) + (size)))
 
#define access_ok(type, addr, size)
 
#define user_addr_max()   (current_thread_info()->addr_limit.seg)
 
#define put_user(x, ptr)   __put_user_check((x), (ptr), sizeof(*(ptr)))
 
#define get_user(x, ptr)   __get_user_check((x), (ptr), sizeof(*(ptr)))
 
#define __put_user(x, ptr)   __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
 
#define __get_user(x, ptr)   __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
 
#define __m(x)   (*(struct __large_struct __user *)(x))
 
#define __get_user_nocheck(x, ptr, size)
 
#define __get_user_check(x, ptr, size)
 
#define __put_user_nocheck(x, ptr, size)
 
#define __put_user_check(x, ptr, size)
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 
#define clear_user(addr, n)
 

Functions

long strncpy_from_user (char *dest, const char __user *src, long count)
 
__must_check long strlen_user (const char __user *str)
 
__must_check long strnlen_user (const char __user *str, long n)
 
__kernel_size_t __copy_user (void *to, const void *from, __kernel_size_t n)
 
__kernel_size_t __clear_user (void *addr, __kernel_size_t size)
 
int fixup_exception (struct pt_regs *regs)
 
unsigned long search_exception_table (unsigned long addr)
 
struct exception_table_entrysearch_exception_tables (unsigned long addr)
 
voidset_exception_table_vec (unsigned int vec, void *handler)
 
int handle_unaligned_access (insn_size_t instruction, struct pt_regs *regs, struct mem_access *ma, int, unsigned long address)
 

Macro Definition Documentation

#define __access_ok (   addr,
  size 
)    (__addr_ok((addr) + (size)))

Definition at line 22 of file uaccess.h.

#define __addr_ok (   addr)    ((unsigned long __force)(addr) < current_thread_info()->addr_limit.seg)

Definition at line 11 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 127 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 
)    __get_user_nocheck((x), (ptr), sizeof(*(ptr)))

Definition at line 51 of file uaccess.h.

#define __get_user_check (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err = -EFAULT; \
unsigned long __gu_val = 0; \
const __typeof__(*(ptr)) *__gu_addr = (ptr); \
if (likely(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 67 of file uaccess.h.

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

Definition at line 56 of file uaccess.h.

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

Definition at line 54 of file uaccess.h.

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

Definition at line 50 of file uaccess.h.

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

Definition at line 88 of file uaccess.h.

#define __put_user_nocheck (   x,
  ptr,
  size 
)
Value:
({ \
long __pu_err; \
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
__typeof__(*(ptr)) __pu_val = x; \
__put_user_size(__pu_val, __pu_addr, (size), __pu_err); \
__pu_err; \
})

Definition at line 78 of file uaccess.h.

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

Definition at line 24 of file uaccess.h.

#define clear_user (   addr,
  n 
)
Value:
({ \
void __user * __cl_addr = (addr); \
unsigned long __cl_size = (n); \
if (__cl_size && access_ok(VERIFY_WRITE, \
((unsigned long)(__cl_addr)), __cl_size)) \
__cl_size = __clear_user(__cl_addr, __cl_size); \
\
__cl_size; \
})

Definition at line 135 of file uaccess.h.

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

Definition at line 43 of file uaccess.h.

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

Definition at line 42 of file uaccess.h.

#define user_addr_max ( )    (current_thread_info()->addr_limit.seg)

Definition at line 28 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 8 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 9 of file uaccess.h.

Function Documentation

__kernel_size_t __clear_user ( void addr,
__kernel_size_t  size 
)

Definition at line 116 of file usercopy.c.

__kernel_size_t __copy_user ( void to,
const void from,
__kernel_size_t  n 
)

Definition at line 27 of file nommu.c.

int fixup_exception ( struct pt_regs regs)

Definition at line 7 of file extable.c.

int handle_unaligned_access ( insn_size_t  instruction,
struct pt_regs regs,
struct mem_access ma,
int  ,
unsigned long  address 
)

Definition at line 303 of file traps_32.c.

unsigned long search_exception_table ( unsigned long  addr)

Definition at line 43 of file extable.c.

struct exception_table_entry* search_exception_tables ( unsigned long  addr)
read

Definition at line 51 of file extable.c.

void* set_exception_table_vec ( unsigned int  vec,
void handler 
)

Definition at line 761 of file traps_32.c.

__must_check long strlen_user ( const char __user str)

strlen_user: - Get the size of a user string INCLUDING final NUL. : The string to measure.

Context: User context only. This function may sleep.

Get the size of a NUL-terminated string in user space.

Returns the size of the string INCLUDING the terminating NUL. On exception, returns 0.

If there is a limit on the length of a valid string, you may wish to consider using strnlen_user() instead.

Definition at line 126 of file strnlen_user.c.

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

strncpy_from_user: - Copy a NUL terminated string from userspace. : Destination address, in kernel space. This buffer must be at least bytes long. : Source address, in user space. : Maximum number of bytes to copy, including the trailing NUL.

Copies a NUL-terminated string from userspace to kernel space.

On success, returns the length of the string (not including the trailing NUL).

If access to userspace fails, returns -EFAULT (some data may have been copied).

If is smaller than the length of the string, copies bytes and returns .

Definition at line 20 of file uaccess.c.

__must_check long strnlen_user ( const char __user str,
long  count 
)

strnlen_user: - Get the size of a user string INCLUDING final NUL. : The string to measure. : Maximum count (including NUL character)

Context: User context only. This function may sleep.

Get the size of a NUL-terminated string in user space.

Returns the size of the string INCLUDING the terminating NUL. If the string is too long, returns 'count+1'. On exception (or invalid count), returns 0.

Definition at line 72 of file uaccess.c.