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

Go to the source code of this file.

Data Structures

struct  exception_table_entry
 

Macros

#define HAVE_ARCH_UNMAPPED_AREA   /* we decide where to put mmaps */
 
#define __ptr(x)   ((unsigned long __force *)(x))
 
#define VERIFY_READ   0
 
#define VERIFY_WRITE   1
 
#define __range_ok(addr, size)   ___range_ok((unsigned long) (addr), (unsigned long) (size))
 
#define access_ok(type, addr, size)   (__range_ok((void __user *)(addr), (size)) == 0)
 
#define __access_ok(addr, size)   (__range_ok((addr), (size)) == 0)
 
#define __put_user(x, ptr)
 
#define put_user(x, ptr)
 
#define __put_user_asm(err, x, ptr, bwl, con)
 
#define __get_user(x, ptr)
 
#define get_user(x, ptr)
 
#define __get_user_asm(err, x, ptr, bwl, con)
 
#define ____force(x)   (__force void *)(void __user *)(x)
 
#define clear_user(dst, count)   (memset(____force(dst), 0, (count)), 0)
 
#define __copy_from_user_inatomic(to, from, n)   (memcpy((to), ____force(from), (n)), 0)
 
#define __copy_to_user_inatomic(to, from, n)   (memcpy(____force(to), (from), (n)), 0)
 
#define __clear_user   clear_user
 
#define strlen_user(str)   strnlen_user(str, 32767)
 

Functions

unsigned long search_exception_table (unsigned long)
 
int __put_user_bad (void)
 
int __get_user_bad (void)
 
long strncpy_from_user (char *dst, const char __user *src, long count)
 
long strnlen_user (const char __user *src, long count)
 

Macro Definition Documentation

#define ____force (   x)    (__force void *)(void __user *)(x)

Definition at line 261 of file uaccess.h.

#define __access_ok (   addr,
  size 
)    (__range_ok((addr), (size)) == 0)

Definition at line 66 of file uaccess.h.

#define __clear_user   clear_user

Definition at line 278 of file uaccess.h.

#define __copy_from_user_inatomic (   to,
  from,
  n 
)    (memcpy((to), ____force(from), (n)), 0)

Definition at line 273 of file uaccess.h.

#define __copy_to_user_inatomic (   to,
  from,
  n 
)    (memcpy(____force(to), (from), (n)), 0)

Definition at line 274 of file uaccess.h.

#define __get_user (   x,
  ptr 
)

Definition at line 175 of file uaccess.h.

#define __get_user_asm (   err,
  x,
  ptr,
  bwl,
  con 
)
Value:
asm(" ld"bwl"%I1 %M1,%0 \n" \
" membar \n" \
: con(x) \
: "m" (*__ptr(ptr)))

Definition at line 249 of file uaccess.h.

#define __ptr (   x)    ((unsigned long __force *)(x))

Definition at line 25 of file uaccess.h.

#define __put_user (   x,
  ptr 
)
Value:
({ \
int __pu_err = 0; \
typeof(*(ptr)) __pu_val = (x); \
\
switch (sizeof (*(ptr))) { \
case 1: \
__put_user_asm(__pu_err, __pu_val, ptr, "b", "r"); \
break; \
case 2: \
__put_user_asm(__pu_err, __pu_val, ptr, "h", "r"); \
break; \
case 4: \
__put_user_asm(__pu_err, __pu_val, ptr, "", "r"); \
break; \
case 8: \
__put_user_asm(__pu_err, __pu_val, ptr, "d", "e"); \
break; \
default: \
__pu_err = __put_user_bad(); \
break; \
} \
__pu_err; \
})

Definition at line 93 of file uaccess.h.

#define __put_user_asm (   err,
  x,
  ptr,
  bwl,
  con 
)
Value:
do { \
asm(" st"bwl"%I0 %1,%M0 \n" \
" membar \n" \
: \
: "m" (*__ptr(ptr)), con (x) \
: "memory"); \
} while (0)

Definition at line 160 of file uaccess.h.

#define __range_ok (   addr,
  size 
)    ___range_ok((unsigned long) (addr), (unsigned long) (size))

Definition at line 63 of file uaccess.h.

#define access_ok (   type,
  addr,
  size 
)    (__range_ok((void __user *)(addr), (size)) == 0)

Definition at line 65 of file uaccess.h.

#define clear_user (   dst,
  count 
)    (memset(____force(dst), 0, (count)), 0)

Definition at line 272 of file uaccess.h.

#define get_user (   x,
  ptr 
)
Value:
({ \
const typeof(*(ptr)) __user *_p = (ptr);\
int _e; \
\
_e = __range_ok(_p, sizeof(*_p)); \
if (likely(_e == 0)) \
_e = __get_user((x), _p); \
else \
(x) = (typeof(x)) 0; \
_e; \
})

Definition at line 212 of file uaccess.h.

#define HAVE_ARCH_UNMAPPED_AREA   /* we decide where to put mmaps */

Definition at line 23 of file uaccess.h.

#define put_user (   x,
  ptr 
)
Value:
({ \
typeof(*(ptr)) __user *_p = (ptr); \
int _e; \
\
_e = __range_ok(_p, sizeof(*_p)); \
if (_e == 0) \
_e = __put_user((x), _p); \
_e; \
})

Definition at line 120 of file uaccess.h.

#define strlen_user (   str)    strnlen_user(str, 32767)

Definition at line 315 of file uaccess.h.

#define VERIFY_READ   0

Definition at line 27 of file uaccess.h.

#define VERIFY_WRITE   1

Definition at line 28 of file uaccess.h.

Function Documentation

int __get_user_bad ( void  )
int __put_user_bad ( void  )
unsigned long search_exception_table ( unsigned  long)

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

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.