uaccess.h (15f3d81a8c8a564cbc8642cf95c548d02db035a7) uaccess.h (12700c17fc286149324f92d6d380bc48e43f253d)
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 03, 04 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2007 Maciej W. Rozycki

--- 30 unchanged lines hidden (view full) ---

39#define __UA_ADDR ".dword"
40#define __UA_LA "dla"
41#define __UA_ADDU "daddu"
42#define __UA_t0 "$12"
43#define __UA_t1 "$13"
44
45#endif /* CONFIG_64BIT */
46
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 03, 04 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2007 Maciej W. Rozycki

--- 30 unchanged lines hidden (view full) ---

39#define __UA_ADDR ".dword"
40#define __UA_LA "dla"
41#define __UA_ADDU "daddu"
42#define __UA_t0 "$12"
43#define __UA_t1 "$13"
44
45#endif /* CONFIG_64BIT */
46
47/*
48 * access_ok: - Checks if a user space pointer is valid
49 * @addr: User space pointer to start of block to check
50 * @size: Size of block to check
51 *
52 * Context: User context only. This function may sleep if pagefaults are
53 * enabled.
54 *
55 * Checks if a pointer to a block of memory in user space is valid.
56 *
57 * Returns true (nonzero) if the memory block may be valid, false (zero)
58 * if it is definitely invalid.
59 *
60 * Note that, depending on architecture, this function probably just
61 * checks that the pointer is in the user space range - after calling
62 * this function, memory access functions may still return -EFAULT.
63 */
47#include <asm-generic/access_ok.h>
64
48
65static inline int __access_ok(const void __user *p, unsigned long size)
66{
67 unsigned long addr = (unsigned long)p;
68 unsigned long limit = TASK_SIZE_MAX;
69
70 return (size <= limit) && (addr <= (limit - size));
71}
72
73#define access_ok(addr, size) \
74 likely(__access_ok((addr), (size)))
75
76/*
77 * put_user: - Write a simple value into user space.
78 * @x: Value to copy to user space.
79 * @ptr: Destination address, in user space.
80 *
81 * Context: User context only. This function may sleep if pagefaults are
82 * enabled.
83 *

--- 508 unchanged lines hidden ---
49/*
50 * put_user: - Write a simple value into user space.
51 * @x: Value to copy to user space.
52 * @ptr: Destination address, in user space.
53 *
54 * Context: User context only. This function may sleep if pagefaults are
55 * enabled.
56 *

--- 508 unchanged lines hidden ---