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

Go to the source code of this file.

Macros

#define probe_kernel_address(addr, retval)
 

Functions

long probe_kernel_read (void *dst, const void *src, size_t size)
 
long __probe_kernel_read (void *dst, const void *src, size_t size)
 
long notrace probe_kernel_write (void *dst, const void *src, size_t size)
 
long notrace __probe_kernel_write (void *dst, const void *src, size_t size)
 

Macro Definition Documentation

#define probe_kernel_address (   addr,
  retval 
)
Value:
({ \
long ret; \
mm_segment_t old_fs = get_fs(); \
pagefault_disable(); \
ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
pagefault_enable(); \
set_fs(old_fs); \
ret; \
})

probe_kernel_address(): safely attempt to read from a location : address to read from - its type is type typeof(retval)*

Return values
read into this variable

Safely read from address into variable . If a kernel fault happens, handle that and return -EFAULT. We ensure that the __get_user() is executed in atomic context so that do_page_fault() doesn't attempt to take mmap_sem. This makes probe_kernel_address() suitable for use within regions where the caller already holds mmap_sem, or other locks which nest inside mmap_sem. This must be a macro because __get_user() needs to know the types of the args.

We don't include enough header files to be able to do the set_fs(). We require that the probe_kernel_address() caller will do that.

Definition at line 74 of file uaccess.h.

Function Documentation

long __probe_kernel_read ( void dst,
const void src,
size_t  size 
)

Definition at line 21 of file maccess.c.

long notrace __probe_kernel_write ( void dst,
const void src,
size_t  size 
)

Definition at line 49 of file maccess.c.

long probe_kernel_read ( void dst,
const void src,
size_t  size 
)

Definition at line 19 of file maccess.c.

long notrace probe_kernel_write ( void dst,
const void src,
size_t  size 
)

Definition at line 58 of file maccess.c.