Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
uaccess_32.h File Reference
#include <asm/processor.h>

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 
struct  __large_struct
 

Macros

#define ARCH_HAS_SORT_EXTABLE
 
#define ARCH_HAS_SEARCH_EXTABLE
 
#define KERNEL_DS   ((mm_segment_t) { 0 })
 
#define USER_DS   ((mm_segment_t) { -1 })
 
#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define get_ds()   (KERNEL_DS)
 
#define get_fs()   (current->thread.current_ds)
 
#define set_fs(val)   ((current->thread.current_ds) = (val))
 
#define segment_eq(a, b)   ((a).seg == (b).seg)
 
#define __user_ok(addr, size)   ({ (void)(size); (addr) < STACK_TOP; })
 
#define __kernel_ok   (segment_eq(get_fs(), KERNEL_DS))
 
#define __access_ok(addr, size)   (__user_ok((addr) & get_fs().seg,(size)))
 
#define access_ok(type, addr, size)   ({ (void)(type); __access_ok((unsigned long)(addr), size); })
 
#define put_user(x, ptr)
 
#define get_user(x, ptr)
 
#define __put_user(x, ptr)   __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
#define __get_user(x, ptr)   __get_user_nocheck((x),(ptr),sizeof(*(ptr)),__typeof__(*(ptr)))
 
#define __m(x)   ((struct __large_struct __user *)(x))
 
#define __put_user_check(x, addr, size)
 
#define __put_user_nocheck(x, addr, size)
 
#define __put_user_asm(x, size, addr, ret)
 
#define __get_user_check(x, addr, size, type)
 
#define __get_user_check_ret(x, addr, size, type, retval)
 
#define __get_user_nocheck(x, addr, size, type)
 
#define __get_user_nocheck_ret(x, addr, size, type, retval)
 
#define __get_user_asm(x, size, addr, ret)
 
#define __get_user_asm_ret(x, size, addr, retval)
 
#define __copy_to_user_inatomic   __copy_to_user
 
#define __copy_from_user_inatomic   __copy_from_user
 

Functions

unsigned long search_extables_range (unsigned long addr, unsigned long *g2)
 
void __ret_efault (void)
 
int __put_user_bad (void)
 
int __get_user_bad (void)
 
unsigned long __copy_user (void __user *to, const void __user *from, unsigned long size)
 
__must_check long strlen_user (const char __user *str)
 
__must_check long strnlen_user (const char __user *str, long n)
 

Macro Definition Documentation

#define __access_ok (   addr,
  size 
)    (__user_ok((addr) & get_fs().seg,(size)))

Definition at line 49 of file uaccess_32.h.

#define __copy_from_user_inatomic   __copy_from_user

Definition at line 278 of file uaccess_32.h.

#define __copy_to_user_inatomic   __copy_to_user

Definition at line 277 of file uaccess_32.h.

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

Definition at line 110 of file uaccess_32.h.

#define __get_user_asm (   x,
  size,
  addr,
  ret 
)
Value:
__asm__ __volatile__( \
"/* Get user asm, inline. */\n" \
"1:\t" "ld"#size " %2, %1\n\t" \
"clr %0\n" \
"2:\n\n\t" \
".section .fixup,#alloc,#execinstr\n\t" \
".align 4\n" \
"3:\n\t" \
"clr %1\n\t" \
"b 2b\n\t" \
" mov %3, %0\n\n\t" \
".previous\n\t" \
".section __ex_table,#alloc\n\t" \
".align 4\n\t" \
".word 1b, 3b\n\n\t" \
".previous\n\t" \
: "=&r" (ret), "=&r" (x) : "m" (*__m(addr)), \
"i" (-EFAULT))

Definition at line 201 of file uaccess_32.h.

#define __get_user_asm_ret (   x,
  size,
  addr,
  retval 
)
Value:
if (__builtin_constant_p(retval) && retval == -EFAULT) \
__asm__ __volatile__( \
"/* Get user asm ret, inline. */\n" \
"1:\t" "ld"#size " %1, %0\n\n\t" \
".section __ex_table,#alloc\n\t" \
".align 4\n\t" \
".word 1b,__ret_efault\n\n\t" \
".previous\n\t" \
: "=&r" (x) : "m" (*__m(addr))); \
else \
__asm__ __volatile__( \
"/* Get user asm ret, inline. */\n" \
"1:\t" "ld"#size " %1, %0\n\n\t" \
".section .fixup,#alloc,#execinstr\n\t" \
".align 4\n" \
"3:\n\t" \
"ret\n\t" \
" restore %%g0, %2, %%o0\n\n\t" \
".previous\n\t" \
".section __ex_table,#alloc\n\t" \
".align 4\n\t" \
".word 1b, 3b\n\n\t" \
".previous\n\t" \
: "=&r" (x) : "m" (*__m(addr)), "i" (retval))

Definition at line 221 of file uaccess_32.h.

#define __get_user_check (   x,
  addr,
  size,
  type 
)
Value:
({ \
register int __gu_ret; \
register unsigned long __gu_val; \
switch (size) { \
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \
case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \
case 4: __get_user_asm(__gu_val,,addr,__gu_ret); break; \
case 8: __get_user_asm(__gu_val,d,addr,__gu_ret); break; \
default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \
} } else { __gu_val = 0; __gu_ret = -EFAULT; } x = (type) __gu_val; __gu_ret; })

Definition at line 157 of file uaccess_32.h.

#define __get_user_check_ret (   x,
  addr,
  size,
  type,
  retval 
)
Value:
({ \
register unsigned long __gu_val __asm__ ("l1"); \
switch (size) { \
case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \
case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \
case 4: __get_user_asm_ret(__gu_val,,addr,retval); break; \
case 8: __get_user_asm_ret(__gu_val,d,addr,retval); break; \
default: if (__get_user_bad()) return retval; \
} x = (type) __gu_val; } else return retval; })

Definition at line 169 of file uaccess_32.h.

#define __get_user_nocheck (   x,
  addr,
  size,
  type 
)
Value:
({ \
register int __gu_ret; \
register unsigned long __gu_val; \
switch (size) { \
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \
case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \
case 4: __get_user_asm(__gu_val,,addr,__gu_ret); break; \
case 8: __get_user_asm(__gu_val,d,addr,__gu_ret); break; \
default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \
} x = (type) __gu_val; __gu_ret; })

Definition at line 180 of file uaccess_32.h.

#define __get_user_nocheck_ret (   x,
  addr,
  size,
  type,
  retval 
)
Value:
({ \
register unsigned long __gu_val __asm__ ("l1"); \
switch (size) { \
case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \
case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \
case 4: __get_user_asm_ret(__gu_val,,addr,retval); break; \
case 8: __get_user_asm_ret(__gu_val,d,addr,retval); break; \
default: if (__get_user_bad()) return retval; \
} x = (type) __gu_val; })

Definition at line 191 of file uaccess_32.h.

#define __kernel_ok   (segment_eq(get_fs(), KERNEL_DS))

Definition at line 48 of file uaccess_32.h.

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

Definition at line 113 of file uaccess_32.h.

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

Definition at line 109 of file uaccess_32.h.

#define __put_user_asm (   x,
  size,
  addr,
  ret 
)
Value:
__asm__ __volatile__( \
"/* Put user asm, inline. */\n" \
"1:\t" "st"#size " %1, %2\n\t" \
"clr %0\n" \
"2:\n\n\t" \
".section .fixup,#alloc,#execinstr\n\t" \
".align 4\n" \
"3:\n\t" \
"b 2b\n\t" \
" mov %3, %0\n\t" \
".previous\n\n\t" \
".section __ex_table,#alloc\n\t" \
".align 4\n\t" \
".word 1b, 3b\n\t" \
".previous\n\n\t" \
: "=&r" (ret) : "r" (x), "m" (*__m(addr)), \
"i" (-EFAULT))

Definition at line 136 of file uaccess_32.h.

#define __put_user_check (   x,
  addr,
  size 
)
Value:
({ \
register int __pu_ret; \
switch (size) { \
case 1: __put_user_asm(x,b,addr,__pu_ret); break; \
case 2: __put_user_asm(x,h,addr,__pu_ret); break; \
case 4: __put_user_asm(x,,addr,__pu_ret); break; \
case 8: __put_user_asm(x,d,addr,__pu_ret); break; \
default: __pu_ret = __put_user_bad(); break; \
} } else { __pu_ret = -EFAULT; } __pu_ret; })

Definition at line 115 of file uaccess_32.h.

#define __put_user_nocheck (   x,
  addr,
  size 
)
Value:
({ \
register int __pu_ret; \
switch (size) { \
case 1: __put_user_asm(x,b,addr,__pu_ret); break; \
case 2: __put_user_asm(x,h,addr,__pu_ret); break; \
case 4: __put_user_asm(x,,addr,__pu_ret); break; \
case 8: __put_user_asm(x,d,addr,__pu_ret); break; \
default: __pu_ret = __put_user_bad(); break; \
} __pu_ret; })

Definition at line 126 of file uaccess_32.h.

#define __user_ok (   addr,
  size 
)    ({ (void)(size); (addr) < STACK_TOP; })

Definition at line 47 of file uaccess_32.h.

#define access_ok (   type,
  addr,
  size 
)    ({ (void)(type); __access_ok((unsigned long)(addr), size); })

Definition at line 50 of file uaccess_32.h.

#define ARCH_HAS_SEARCH_EXTABLE

Definition at line 22 of file uaccess_32.h.

#define ARCH_HAS_SORT_EXTABLE

Definition at line 21 of file uaccess_32.h.

#define get_ds (   void)    (KERNEL_DS)

Definition at line 36 of file uaccess_32.h.

#define get_fs (   void)    (current->thread.current_ds)

Definition at line 37 of file uaccess_32.h.

#define get_user (   x,
  ptr 
)
Value:
({ \
unsigned long __gu_addr = (unsigned long)(ptr); \
__chk_user_ptr(ptr); \
__get_user_check((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); })

Definition at line 99 of file uaccess_32.h.

#define KERNEL_DS   ((mm_segment_t) { 0 })

Definition at line 30 of file uaccess_32.h.

#define put_user (   x,
  ptr 
)
Value:
({ \
unsigned long __pu_addr = (unsigned long)(ptr); \
__chk_user_ptr(ptr); \
__put_user_check((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); })

Definition at line 94 of file uaccess_32.h.

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

Definition at line 40 of file uaccess_32.h.

#define set_fs (   val)    ((current->thread.current_ds) = (val))

Definition at line 38 of file uaccess_32.h.

#define USER_DS   ((mm_segment_t) { -1 })

Definition at line 31 of file uaccess_32.h.

#define VERIFY_READ   0

Definition at line 33 of file uaccess_32.h.

#define VERIFY_WRITE   1

Definition at line 34 of file uaccess_32.h.

Function Documentation

unsigned long __copy_user ( void __user to,
const void __user from,
unsigned long  size 
)
int __get_user_bad ( void  )
int __put_user_bad ( void  )
void __ret_efault ( void  )
unsigned long search_extables_range ( unsigned long  addr,
unsigned long g2 
)

Definition at line 90 of file extable.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.

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