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

Go to the source code of this file.

Data Structures

struct  __large_struct
 
struct  exception_table_entry
 

Macros

#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define get_ds()   (KERNEL_DS)
 
#define get_fs()   (current_thread_info()->addr_limit)
 
#define segment_eq(a, b)   ((a).seg == (b).seg)
 
#define __ua_size(size)   ((__builtin_constant_p(size) && (signed long) (size) > 0) ? 0 : (size))
 
#define __access_ok(addr, size)
 
#define access_ok(type, addr, size)   likely(__access_ok((unsigned long)(addr), (size)))
 
#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_common(val, size, ptr)
 
#define __get_user_nocheck(x, ptr, size)
 
#define __get_user_check(x, ptr, size)
 
#define __get_user_asm(val, insn, addr)
 
#define __put_user_nocheck(val, ptr, size)
 
#define __put_user_check(val, ptr, size)
 
#define __put_user_asm(insn, ptr)
 
#define __copy_from_user(to, from, len)   __copy_tofrom_user((to), (from), (len))
 
#define __copy_to_user(to, from, len)   __copy_tofrom_user((to), (from), (len))
 
#define __copy_in_user(to, from, len)   __copy_from_user(to, from, len)
 

Functions

void __get_user_unknown (void)
 
void __put_user_unknown (void)
 
int __copy_tofrom_user (void *to, const void *from, unsigned long len)
 
unsigned long __clear_user (void __user *src, unsigned long size)
 
int __strncpy_from_user (char *dst, const char *src, long len)
 
int __strlen_user (const char *src)
 
int __strnlen_user (const char *str, long len)
 
int fixup_exception (struct pt_regs *regs)
 

Macro Definition Documentation

#define __access_ok (   addr,
  size 
)
Value:
(((long)((get_fs().seg) & \
((addr) | ((addr) + (size)) | \
__ua_size(size)))) == 0)

Definition at line 51 of file uaccess.h.

#define __copy_from_user (   to,
  from,
  len 
)    __copy_tofrom_user((to), (from), (len))

Definition at line 323 of file uaccess.h.

#define __copy_in_user (   to,
  from,
  len 
)    __copy_from_user(to, from, len)

Definition at line 341 of file uaccess.h.

#define __copy_to_user (   to,
  from,
  len 
)    __copy_tofrom_user((to), (from), (len))

Definition at line 326 of file uaccess.h.

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

Definition at line 137 of file uaccess.h.

#define __get_user_asm (   val,
  insn,
  addr 
)
Value:
{ \
long __gu_tmp; \
\
__asm__ __volatile__( \
"1:" insn " %1, %3\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3:li %0, %4\n" \
"j 2b\n" \
".previous\n" \
".section __ex_table,\"a\"\n" \
".word 1b, 3b\n" \
".previous\n" \
: "=r" (__gu_err), "=r" (__gu_tmp) \
: "0" (0), "o" (__m(addr)), "i" (-EFAULT)); \
\
(val) = (__typeof__(*(addr))) __gu_tmp; \
}

Definition at line 190 of file uaccess.h.

#define __get_user_check (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err = -EFAULT; \
const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \
\
if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \
__get_user_common((x), size, __gu_ptr); \
\
__gu_err; \
})

Definition at line 179 of file uaccess.h.

#define __get_user_common (   val,
  size,
  ptr 
)
Value:
do { \
switch (size) { \
case 1: \
__get_user_asm(val, "lb", ptr); \
break; \
case 2: \
__get_user_asm(val, "lh", ptr); \
break; \
case 4: \
__get_user_asm(val, "lw", ptr); \
break; \
case 8: \
if ((copy_from_user((void *)&val, ptr, 8)) == 0) \
__gu_err = 0; \
else \
__gu_err = -EFAULT; \
break; \
default: \
__get_user_unknown(); \
break; \
} \
} while (0)

Definition at line 148 of file uaccess.h.

#define __get_user_nocheck (   x,
  ptr,
  size 
)
Value:
({ \
long __gu_err = 0; \
__get_user_common((x), size, ptr); \
__gu_err; \
})

Definition at line 172 of file uaccess.h.

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

Definition at line 140 of file uaccess.h.

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

Definition at line 115 of file uaccess.h.

#define __put_user_asm (   insn,
  ptr 
)
Value:
__asm__ __volatile__( \
"1:" insn " %2, %3\n" \
"2:\n" \
".section .fixup,\"ax\"\n" \
"3:li %0, %4\n" \
"j 2b\n" \
".previous\n" \
".section __ex_table,\"a\"\n" \
".word 1b, 3b\n" \
".previous\n" \
: "=r" (__pu_err) \
: "0" (0), "r" (__pu_val), "o" (__m(ptr)), \
"i" (-EFAULT));

Definition at line 275 of file uaccess.h.

#define __put_user_check (   val,
  ptr,
  size 
)
Value:
({ \
__typeof__(*(ptr)) __user *__pu_addr = (ptr); \
__typeof__(*(ptr)) __pu_val = (val); \
long __pu_err = -EFAULT; \
\
if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) { \
switch (size) { \
case 1: \
__put_user_asm("sb", __pu_addr); \
break; \
case 2: \
__put_user_asm("sh", __pu_addr); \
break; \
case 4: \
__put_user_asm("sw", __pu_addr); \
break; \
case 8: \
if ((__copy_to_user((void *)__pu_addr, &__pu_val, 8)) == 0)\
__pu_err = 0; \
else \
__pu_err = -EFAULT; \
break; \
default: \
__put_user_unknown(); \
break; \
} \
} \
__pu_err; \
})

Definition at line 244 of file uaccess.h.

#define __put_user_nocheck (   val,
  ptr,
  size 
)
Value:
({ \
__typeof__(*(ptr)) __pu_val; \
long __pu_err = 0; \
\
__pu_val = (val); \
switch (size) { \
case 1: \
__put_user_asm("sb", ptr); \
break; \
case 2: \
__put_user_asm("sh", ptr); \
break; \
case 4: \
__put_user_asm("sw", ptr); \
break; \
case 8: \
if ((__copy_to_user((void *)ptr, &__pu_val, 8)) == 0) \
__pu_err = 0; \
else \
__pu_err = -EFAULT; \
break; \
default: \
__put_user_unknown(); \
break; \
} \
__pu_err; \
})

Definition at line 214 of file uaccess.h.

#define __ua_size (   size)    ((__builtin_constant_p(size) && (signed long) (size) > 0) ? 0 : (size))

Definition at line 28 of file uaccess.h.

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

Definition at line 56 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 11 of file uaccess.h.

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

Definition at line 12 of file uaccess.h.

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

Definition at line 94 of file uaccess.h.

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

Definition at line 75 of file uaccess.h.

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

Definition at line 13 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

unsigned long __clear_user ( void __user addr,
unsigned long  size 
)

__clear_user: - Zero a block of memory in user space, with less checking. : Destination address, in user space.
: Number of bytes to zero.

Zero a block of memory in user space. Caller must check the specified block with access_ok() before calling this function.

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

Definition at line 158 of file uaccess_with_memcpy.c.

int __copy_tofrom_user ( void to,
const void from,
unsigned long  len 
)
void __get_user_unknown ( void  )
void __put_user_unknown ( void  )
int __strlen_user ( const char src)
int __strncpy_from_user ( char dst,
const char src,
long  len 
)

Definition at line 69 of file usercopy.c.

int __strnlen_user ( const char str,
long  len 
)
int fixup_exception ( struct pt_regs regs)

Definition at line 7 of file extable.c.