Linux Kernel
3.7.1
|
#include <linux/errno.h>
#include <linux/compiler.h>
#include <linux/thread_info.h>
#include <linux/string.h>
#include <asm/asm.h>
#include <asm/page.h>
#include <asm/smap.h>
#include <asm/uaccess_64.h>
Go to the source code of this file.
Data Structures | |
struct | exception_table_entry |
struct | __large_struct |
Functions | |
int | fixup_exception (struct pt_regs *regs) |
int | early_fixup_exception (unsigned long *ip) |
int | __get_user_1 (void) |
int | __get_user_2 (void) |
int | __get_user_4 (void) |
int | __get_user_8 (void) |
int | __get_user_bad (void) |
void | __put_user_bad (void) |
void | __put_user_1 (void) |
void | __put_user_2 (void) |
void | __put_user_4 (void) |
void | __put_user_8 (void) |
unsigned long | copy_from_user_nmi (void *to, const void __user *from, unsigned long n) |
__must_check long | strncpy_from_user (char *dst, const char __user *src, long count) |
__must_check long | strlen_user (const char __user *str) |
__must_check long | strnlen_user (const char __user *str, long n) |
unsigned long __must_check | clear_user (void __user *mem, unsigned long len) |
unsigned long __must_check | __clear_user (void __user *mem, unsigned long len) |
#define __addr_ok | ( | addr | ) | ((unsigned long __force)(addr) < user_addr_max()) |
#define __get_user | ( | x, | |
ptr | |||
) | __get_user_nocheck((x), (ptr), sizeof(*(ptr))) |
__get_user: - Get a simple variable from user space, with less checking. : Variable to store result. : Source address, in user space.
Context: User context only. This function may sleep.
This macro copies a single simple variable from user space to kernel space. It supports simple types like char and int, but not larger data types like structures or arrays.
must have pointer-to-simple-variable type, and the result of dereferencing must be assignable to without a cast.
Caller must check the pointer with access_ok() before calling this function.
Returns zero on success, or -EFAULT on error. On error, the variable is set to zero.
#define __get_user_8 | ( | __ret_gu, | |
__val_gu, | |||
ptr | |||
) | __get_user_x(8, __ret_gu, __val_gu, ptr) |
get_user: - Get a simple variable from user space. : Variable to store result. : Source address, in user space.
Context: User context only. This function may sleep.
This macro copies a single simple variable from user space to kernel space. It supports simple types like char and int, but not larger data types like structures or arrays.
must have pointer-to-simple-variable type, and the result of dereferencing must be assignable to without a cast.
Returns zero on success, or -EFAULT on error. On error, the variable is set to zero.
#define __get_user_unaligned __get_user |
__put_user: - Write a simple value into user space, with less checking. : Value to copy to user space. : Destination address, in user space.
Context: User context only. This function may sleep.
This macro copies a single simple value from kernel space to user space. It supports simple types like char and int, but not larger data types like structures or arrays.
must have pointer-to-simple-variable type, and must be assignable to the result of dereferencing .
Caller must check the pointer with access_ok() before calling this function.
Returns zero on success, or -EFAULT on error.
#define __put_user_asm_ex_u64 | ( | x, | |
addr | |||
) | __put_user_asm_ex(x, addr, "q", "", "er") |
#define __put_user_unaligned __put_user |
#define __put_user_x8 | ( | x, | |
ptr, | |||
__ret_pu | |||
) | __put_user_x(8, x, ptr, __ret_pu) |
#define access_ok | ( | type, | |
addr, | |||
size | |||
) | (likely(__range_not_ok(addr, size, user_addr_max()) == 0)) |
access_ok: - Checks if a user space pointer is valid : Type of access: VERIFY_READ or VERIFY_WRITE. Note that VERIFY_WRITE is a superset of VERIFY_READ - if it is safe to write to a block, it is always safe to read from it. : User space pointer to start of block to check : Size of block to check
Context: User context only. This function may sleep.
Checks if a pointer to a block of memory in user space is valid.
Returns true (nonzero) if the memory block may be valid, false (zero) if it is definitely invalid.
Note that, depending on architecture, this function probably just checks that the pointer is in the user space range - after calling this function, memory access functions may still return -EFAULT.
#define get_fs | ( | void | ) | (current_thread_info()->addr_limit) |
#define get_user_catch | ( | err | ) | uaccess_catch(err) |
#define get_user_try uaccess_try |
#define KERNEL_DS MAKE_MM_SEG(-1UL) |
#define MAKE_MM_SEG | ( | s | ) | ((mm_segment_t) { (s) }) |
#define put_user_catch | ( | err | ) |
#define set_fs | ( | x | ) | (current_thread_info()->addr_limit = (x)) |
#define uaccess_catch | ( | err | ) |
#define uaccess_try |
#define user_addr_max | ( | ) | (current_thread_info()->addr_limit.seg) |
#define USER_DS MAKE_MM_SEG(TASK_SIZE_MAX) |
unsigned long __must_check __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.
unsigned long __must_check clear_user | ( | void __user * | to, |
unsigned long | n | ||
) |
clear_user: - Zero a block of memory in user space. : 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.
clear_user: - Zero a block of memory in user space. : Destination address, in user space.
: Number of bytes to zero.
Zero a block of memory in user space.
Returns number of bytes that could not be cleared. On success, this will be zero.
Definition at line 224 of file usercopy.c.
Definition at line 17 of file usercopy.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.
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 .
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.