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 <asm/page.h>
#include <asm/cache.h>
#include <asm/errno.h>
#include <asm-generic/uaccess-unaligned.h>

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 
struct  exception_data
 

Macros

#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define KERNEL_DS   ((mm_segment_t){0})
 
#define USER_DS   ((mm_segment_t){1})
 
#define segment_eq(a, b)   ((a).seg == (b).seg)
 
#define get_ds()   (KERNEL_DS)
 
#define get_fs()   (current_thread_info()->addr_limit)
 
#define set_fs(x)   (current_thread_info()->addr_limit = (x))
 
#define put_user   __put_user
 
#define get_user   __get_user
 
#define LDD_KERNEL(ptr)   __get_kernel_bad();
 
#define LDD_USER(ptr)   __get_user_bad();
 
#define STD_KERNEL(x, ptr)   __put_kernel_asm64(x,ptr)
 
#define STD_USER(x, ptr)   __put_user_asm64(x,ptr)
 
#define ASM_WORD_INSN   ".word\t"
 
#define ASM_EXCEPTIONTABLE_ENTRY(fault_addr, except_addr)
 
#define __get_user(x, ptr)
 
#define __get_kernel_asm(ldx, ptr)
 
#define __get_user_asm(ldx, ptr)
 
#define __put_user(x, ptr)
 
#define __put_kernel_asm(stx, x, ptr)
 
#define __put_user_asm(stx, x, ptr)
 
#define __put_kernel_asm64(__val, ptr)
 
#define __put_user_asm64(__val, ptr)
 
#define user_addr_max()   (~0UL)
 
#define strnlen_user   lstrnlen_user
 
#define strlen_user(str)   lstrnlen_user(str, 0x7fffffffL)
 
#define clear_user   lclear_user
 
#define __clear_user   lclear_user
 
#define __copy_to_user   copy_to_user
 
#define __copy_in_user   copy_in_user
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 

Functions

int __get_kernel_bad (void)
 
int __get_user_bad (void)
 
int __put_kernel_bad (void)
 
int __put_user_bad (void)
 
unsigned long lcopy_to_user (void __user *, const void *, unsigned long)
 
unsigned long lcopy_from_user (void *, const void __user *, unsigned long)
 
unsigned long lcopy_in_user (void __user *, const void __user *, unsigned long)
 
long strncpy_from_user (char *, const char __user *, long)
 
unsigned lclear_user (void __user *, unsigned long)
 
long lstrnlen_user (const char __user *, long)
 
unsigned long copy_to_user (void __user *dst, const void *src, unsigned long len)
 
unsigned long __copy_from_user (void *dst, const void __user *src, unsigned long len)
 
unsigned long copy_in_user (void __user *dst, const void __user *src, unsigned long len)
 
void copy_from_user_overflow (void) __compiletime_warning("copy_from_user() buffer size is not provably correct")
 
int fixup_exception (struct pt_regs *regs)
 

Macro Definition Documentation

#define __clear_user   lclear_user

Definition at line 232 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 240 of file uaccess.h.

#define __copy_in_user   copy_in_user

Definition at line 238 of file uaccess.h.

#define __copy_to_user   copy_to_user

Definition at line 235 of file uaccess.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 239 of file uaccess.h.

#define __get_kernel_asm (   ldx,
  ptr 
)
Value:
__asm__("\n1:\t" ldx "\t0(%2),%0\n\t" \
: "=r"(__gu_val), "=r"(__gu_err) \
: "r"(ptr), "1"(__gu_err) \
: "r1");

Definition at line 113 of file uaccess.h.

#define __get_user (   x,
  ptr 
)
Value:
({ \
register long __gu_err __asm__ ("r8") = 0; \
register long __gu_val __asm__ ("r9") = 0; \
switch (sizeof(*(ptr))) { \
case 1: __get_kernel_asm("ldb",ptr); break; \
case 2: __get_kernel_asm("ldh",ptr); break; \
case 4: __get_kernel_asm("ldw",ptr); break; \
case 8: LDD_KERNEL(ptr); break; \
default: __get_kernel_bad(); break; \
} \
} \
else { \
switch (sizeof(*(ptr))) { \
case 1: __get_user_asm("ldb",ptr); break; \
case 2: __get_user_asm("ldh",ptr); break; \
case 4: __get_user_asm("ldw",ptr); break; \
case 8: LDD_USER(ptr); break; \
default: __get_user_bad(); break; \
} \
} \
\
(x) = (__typeof__(*(ptr))) __gu_val; \
__gu_err; \
})

Definition at line 85 of file uaccess.h.

#define __get_user_asm (   ldx,
  ptr 
)
Value:
__asm__("\n1:\t" ldx "\t0(%%sr3,%2),%0\n\t" \
: "=r"(__gu_val), "=r"(__gu_err) \
: "r"(ptr), "1"(__gu_err) \
: "r1");

Definition at line 120 of file uaccess.h.

#define __put_kernel_asm (   stx,
  x,
  ptr 
)
Value:
__asm__ __volatile__ ( \
"\n1:\t" stx "\t%2,0(%1)\n\t" \
: "=r"(__pu_err) \
: "r"(ptr), "r"(x), "0"(__pu_err) \
: "r1")

Definition at line 164 of file uaccess.h.

#define __put_kernel_asm64 (   __val,
  ptr 
)
Value:
do { \
u64 __val64 = (u64)(__val); \
u32 hi = (__val64) >> 32; \
u32 lo = (__val64) & 0xffffffff; \
__asm__ __volatile__ ( \
"\n1:\tstw %2,0(%1)" \
"\n2:\tstw %3,4(%1)\n\t" \
: "=r"(__pu_err) \
: "r"(ptr), "r"(hi), "r"(lo), "0"(__pu_err) \
: "r1"); \
} while (0)

Definition at line 183 of file uaccess.h.

#define __put_user (   x,
  ptr 
)
Value:
({ \
register long __pu_err __asm__ ("r8") = 0; \
__typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \
\
switch (sizeof(*(ptr))) { \
case 1: __put_kernel_asm("stb",__x,ptr); break; \
case 2: __put_kernel_asm("sth",__x,ptr); break; \
case 4: __put_kernel_asm("stw",__x,ptr); break; \
case 8: STD_KERNEL(__x,ptr); break; \
default: __put_kernel_bad(); break; \
} \
} \
else { \
switch (sizeof(*(ptr))) { \
case 1: __put_user_asm("stb",__x,ptr); break; \
case 2: __put_user_asm("sth",__x,ptr); break; \
case 4: __put_user_asm("stw",__x,ptr); break; \
case 8: STD_USER(__x,ptr); break; \
default: __put_user_bad(); break; \
} \
} \
\
__pu_err; \
})

Definition at line 127 of file uaccess.h.

#define __put_user_asm (   stx,
  x,
  ptr 
)
Value:
__asm__ __volatile__ ( \
"\n1:\t" stx "\t%2,0(%%sr3,%1)\n\t" \
: "=r"(__pu_err) \
: "r"(ptr), "r"(x), "0"(__pu_err) \
: "r1")

Definition at line 172 of file uaccess.h.

#define __put_user_asm64 (   __val,
  ptr 
)
Value:
do { \
u64 __val64 = (u64)(__val); \
u32 hi = (__val64) >> 32; \
u32 lo = (__val64) & 0xffffffff; \
__asm__ __volatile__ ( \
"\n1:\tstw %2,0(%%sr3,%1)" \
"\n2:\tstw %3,4(%%sr3,%1)\n\t" \
: "=r"(__pu_err) \
: "r"(ptr), "r"(hi), "r"(lo), "0"(__pu_err) \
: "r1"); \
} while (0)

Definition at line 197 of file uaccess.h.

#define ASM_EXCEPTIONTABLE_ENTRY (   fault_addr,
  except_addr 
)
Value:
".section __ex_table,\"aw\"\n" \
ASM_WORD_INSN #fault_addr ", " #except_addr "\n\t" \
".previous\n"

Definition at line 70 of file uaccess.h.

#define ASM_WORD_INSN   ".word\t"

Definition at line 50 of file uaccess.h.

#define clear_user   lclear_user

Definition at line 231 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 20 of file uaccess.h.

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

Definition at line 21 of file uaccess.h.

#define get_user   __get_user

Definition at line 43 of file uaccess.h.

#define KERNEL_DS   ((mm_segment_t){0})

Definition at line 15 of file uaccess.h.

#define LDD_KERNEL (   ptr)    __get_kernel_bad();

Definition at line 46 of file uaccess.h.

#define LDD_USER (   ptr)    __get_user_bad();

Definition at line 47 of file uaccess.h.

#define put_user   __put_user

Definition at line 42 of file uaccess.h.

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

Definition at line 18 of file uaccess.h.

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

Definition at line 22 of file uaccess.h.

#define STD_KERNEL (   x,
  ptr 
)    __put_kernel_asm64(x,ptr)

Definition at line 48 of file uaccess.h.

#define STD_USER (   x,
  ptr 
)    __put_user_asm64(x,ptr)

Definition at line 49 of file uaccess.h.

#define strlen_user (   str)    lstrnlen_user(str, 0x7fffffffL)

Definition at line 230 of file uaccess.h.

#define strnlen_user   lstrnlen_user

Definition at line 229 of file uaccess.h.

#define user_addr_max ( )    (~0UL)

Definition at line 227 of file uaccess.h.

#define USER_DS   ((mm_segment_t){1})

Definition at line 16 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 12 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 13 of file uaccess.h.

Function Documentation

unsigned long __copy_from_user ( void dst,
const void __user src,
unsigned long  len 
)
int __get_kernel_bad ( void  )
int __get_user_bad ( void  )
int __put_kernel_bad ( void  )
int __put_user_bad ( void  )
void copy_from_user_overflow ( void  )

Definition at line 4 of file usercopy.c.

unsigned long copy_in_user ( void __user dst,
const void __user src,
unsigned long  len 
)

Definition at line 28 of file usercopy_64.c.

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

copy_to_user: - Copy a block of data into user space. : Destination address, in user space. : Source address, in kernel space.
: Number of bytes to copy.

Context: User context only. This function may sleep.

Copy data from kernel space to user space.

Returns number of bytes that could not be copied. On success, this will be zero.

Definition at line 21 of file usercopy_64.c.

int fixup_exception ( struct pt_regs regs)

Definition at line 7 of file extable.c.

unsigned lclear_user ( void __user ,
unsigned  long 
)
unsigned long lcopy_from_user ( void ,
const void __user ,
unsigned  long 
)
unsigned long lcopy_in_user ( void __user ,
const void __user ,
unsigned  long 
)
unsigned long lcopy_to_user ( void __user ,
const void ,
unsigned  long 
)
long lstrnlen_user ( const char __user ,
long   
)
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.