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/string.h>
#include <linux/thread_info.h>
#include <asm/ptrace.h>
#include <asm/errno.h>
#include <asm/memory.h>
#include <asm/compiler.h>

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 

Macros

#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define KERNEL_DS   (-1UL)
 
#define get_ds()   (KERNEL_DS)
 
#define USER_DS   TASK_SIZE_64
 
#define get_fs()   (current_thread_info()->addr_limit)
 
#define segment_eq(a, b)   ((a) == (b))
 
#define __addr_ok(addr)
 
#define __range_ok(addr, size)
 
#define access_ok(type, addr, size)   __range_ok(addr, size)
 
#define __get_user_asm(instr, reg, x, addr, err)
 
#define __get_user_err(x, ptr, err)
 
#define __get_user(x, ptr)
 
#define __get_user_error(x, ptr, err)
 
#define __get_user_unaligned   __get_user
 
#define get_user(x, ptr)
 
#define __put_user_asm(instr, reg, x, addr, err)
 
#define __put_user_err(x, ptr, err)
 
#define __put_user(x, ptr)
 
#define __put_user_error(x, ptr, err)
 
#define __put_user_unaligned   __put_user
 
#define put_user(x, ptr)
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 
#define strlen_user(s)   strnlen_user(s, ~0UL >> 1)
 

Functions

int fixup_exception (struct pt_regs *regs)
 
unsigned long __must_check __copy_from_user (void *to, const void __user *from, unsigned long n)
 
unsigned long __must_check __copy_to_user (void __user *to, const void *from, unsigned long n)
 
unsigned long __must_check __copy_in_user (void __user *to, const void __user *from, unsigned long n)
 
unsigned long __must_check __clear_user (void __user *addr, unsigned long n)
 
unsigned long __must_check __strncpy_from_user (char *to, const char __user *from, unsigned long count)
 
unsigned long __must_check __strnlen_user (const char __user *s, long n)
 

Macro Definition Documentation

#define __addr_ok (   addr)
Value:
({ \
unsigned long flag; \
asm("cmp %1, %0; cset %0, lo" \
: "=&r" (flag) \
: "r" (addr), "0" (current_thread_info()->addr_limit) \
: "cc"); \
})

Definition at line 71 of file uaccess.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 268 of file uaccess.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 267 of file uaccess.h.

#define __get_user (   x,
  ptr 
)
Value:
({ \
int __gu_err = 0; \
__get_user_err((x), (ptr), __gu_err); \
__gu_err; \
})

Definition at line 152 of file uaccess.h.

#define __get_user_asm (   instr,
  reg,
  x,
  addr,
  err 
)
Value:
asm volatile( \
"1: " instr " " reg "1, [%2]\n" \
"2:\n" \
" .section .fixup, \"ax\"\n" \
" .align 2\n" \
"3: mov %w0, %3\n" \
" mov %1, #0\n" \
" b 2b\n" \
" .previous\n" \
" .section __ex_table,\"a\"\n" \
" .align 3\n" \
" .quad 1b, 3b\n" \
" .previous" \
: "+r" (err), "=&r" (x) \
: "r" (addr), "i" (-EFAULT))

Definition at line 112 of file uaccess.h.

#define __get_user_err (   x,
  ptr,
  err 
)
Value:
do { \
unsigned long __gu_val; \
__chk_user_ptr(ptr); \
switch (sizeof(*(ptr))) { \
case 1: \
__get_user_asm("ldrb", "%w", __gu_val, (ptr), (err)); \
break; \
case 2: \
__get_user_asm("ldrh", "%w", __gu_val, (ptr), (err)); \
break; \
case 4: \
__get_user_asm("ldr", "%w", __gu_val, (ptr), (err)); \
break; \
case 8: \
__get_user_asm("ldr", "%", __gu_val, (ptr), (err)); \
break; \
default: \
BUILD_BUG(); \
} \
(x) = (__typeof__(*(ptr)))__gu_val; \
} while (0)

Definition at line 129 of file uaccess.h.

#define __get_user_error (   x,
  ptr,
  err 
)
Value:
({ \
__get_user_err((x), (ptr), (err)); \
(void)0; \
})

Definition at line 159 of file uaccess.h.

#define __get_user_unaligned   __get_user

Definition at line 165 of file uaccess.h.

#define __put_user (   x,
  ptr 
)
Value:
({ \
int __pu_err = 0; \
__put_user_err((x), (ptr), __pu_err); \
__pu_err; \
})

Definition at line 213 of file uaccess.h.

#define __put_user_asm (   instr,
  reg,
  x,
  addr,
  err 
)
Value:
asm volatile( \
"1: " instr " " reg "1, [%2]\n" \
"2:\n" \
" .section .fixup,\"ax\"\n" \
" .align 2\n" \
"3: mov %w0, %3\n" \
" b 2b\n" \
" .previous\n" \
" .section __ex_table,\"a\"\n" \
" .align 3\n" \
" .quad 1b, 3b\n" \
" .previous" \
: "+r" (err) \
: "r" (x), "r" (addr), "i" (-EFAULT))

Definition at line 175 of file uaccess.h.

#define __put_user_err (   x,
  ptr,
  err 
)
Value:
do { \
__typeof__(*(ptr)) __pu_val = (x); \
switch (sizeof(*(ptr))) { \
case 1: \
__put_user_asm("strb", "%w", __pu_val, (ptr), (err)); \
break; \
case 2: \
__put_user_asm("strh", "%w", __pu_val, (ptr), (err)); \
break; \
case 4: \
__put_user_asm("str", "%w", __pu_val, (ptr), (err)); \
break; \
case 8: \
__put_user_asm("str", "%", __pu_val, (ptr), (err)); \
break; \
default: \
BUILD_BUG(); \
} \
} while (0)

Definition at line 191 of file uaccess.h.

#define __put_user_error (   x,
  ptr,
  err 
)
Value:
({ \
__put_user_err((x), (ptr), (err)); \
(void)0; \
})

Definition at line 220 of file uaccess.h.

#define __put_user_unaligned   __put_user

Definition at line 226 of file uaccess.h.

#define __range_ok (   addr,
  size 
)
Value:
({ \
unsigned long flag, roksum; \
__chk_user_ptr(addr); \
asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, cc" \
: "=&r" (flag), "=&r" (roksum) \
: "1" (addr), "Ir" (size), \
"r" (current_thread_info()->addr_limit) \
: "cc"); \
})

Definition at line 90 of file uaccess.h.

#define access_ok (   type,
  addr,
  size 
)    __range_ok(addr, size)

Definition at line 102 of file uaccess.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 56 of file uaccess.h.

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

Definition at line 59 of file uaccess.h.

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

Definition at line 167 of file uaccess.h.

#define KERNEL_DS   (-1UL)

Definition at line 55 of file uaccess.h.

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

Definition at line 228 of file uaccess.h.

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

Definition at line 66 of file uaccess.h.

#define strlen_user (   s)    strnlen_user(s, ~0UL >> 1)

Definition at line 285 of file uaccess.h.

#define USER_DS   TASK_SIZE_64

Definition at line 58 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 32 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 33 of file uaccess.h.

Function Documentation

unsigned long __must_check __clear_user ( void __user to,
unsigned long  n 
)

__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.

unsigned long __must_check __copy_from_user ( void to,
const void __user from,
unsigned long  n 
)
unsigned long __must_check __copy_in_user ( void __user to,
const void __user from,
unsigned long  n 
)
unsigned long __must_check __copy_to_user ( void __user to,
const void from,
unsigned long  n 
)

Definition at line 107 of file uaccess_with_memcpy.c.

unsigned long __must_check __strncpy_from_user ( char to,
const char __user from,
unsigned long  count 
)
unsigned long __must_check __strnlen_user ( const char __user s,
long  n 
)
int fixup_exception ( struct pt_regs regs)

Definition at line 7 of file extable.c.