diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2011-08-18 15:08:49 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2011-11-02 09:15:13 -0400 |
commit | fced95cacfc21b441ab33f5e7bbc750327e80325 (patch) | |
tree | 466f87c5d9b361b1f8bc29de03168bfe6d800a04 | |
parent | ece67c8697f32699f6977d3d1ae2ae9f7892a913 (diff) |
um: kill um_uaccess.h
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | arch/um/include/asm/uaccess.h | 89 | ||||
-rw-r--r-- | arch/um/include/shared/um_uaccess.h | 94 |
2 files changed, 84 insertions, 99 deletions
diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h index b9a895d6fa1d..3f22fbf7ca1d 100644 --- a/arch/um/include/asm/uaccess.h +++ b/arch/um/include/asm/uaccess.h | |||
@@ -6,15 +6,15 @@ | |||
6 | #ifndef __UM_UACCESS_H | 6 | #ifndef __UM_UACCESS_H |
7 | #define __UM_UACCESS_H | 7 | #define __UM_UACCESS_H |
8 | 8 | ||
9 | #include <asm/errno.h> | ||
10 | #include <asm/processor.h> | ||
11 | |||
12 | /* thread_info has a mm_segment_t in it, so put the definition up here */ | 9 | /* thread_info has a mm_segment_t in it, so put the definition up here */ |
13 | typedef struct { | 10 | typedef struct { |
14 | unsigned long seg; | 11 | unsigned long seg; |
15 | } mm_segment_t; | 12 | } mm_segment_t; |
16 | 13 | ||
17 | #include "linux/thread_info.h" | 14 | #include <linux/thread_info.h> |
15 | #include <linux/errno.h> | ||
16 | #include <asm/processor.h> | ||
17 | #include <asm/elf.h> | ||
18 | 18 | ||
19 | #define VERIFY_READ 0 | 19 | #define VERIFY_READ 0 |
20 | #define VERIFY_WRITE 1 | 20 | #define VERIFY_WRITE 1 |
@@ -38,7 +38,86 @@ typedef struct { | |||
38 | 38 | ||
39 | #define segment_eq(a, b) ((a).seg == (b).seg) | 39 | #define segment_eq(a, b) ((a).seg == (b).seg) |
40 | 40 | ||
41 | #include "um_uaccess.h" | 41 | #define __under_task_size(addr, size) \ |
42 | (((unsigned long) (addr) < TASK_SIZE) && \ | ||
43 | (((unsigned long) (addr) + (size)) < TASK_SIZE)) | ||
44 | |||
45 | #define __access_ok_vsyscall(type, addr, size) \ | ||
46 | ((type == VERIFY_READ) && \ | ||
47 | ((unsigned long) (addr) >= FIXADDR_USER_START) && \ | ||
48 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | ||
49 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) | ||
50 | |||
51 | #define __addr_range_nowrap(addr, size) \ | ||
52 | ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) | ||
53 | |||
54 | #define access_ok(type, addr, size) \ | ||
55 | (__addr_range_nowrap(addr, size) && \ | ||
56 | (__under_task_size(addr, size) || \ | ||
57 | __access_ok_vsyscall(type, addr, size) || \ | ||
58 | segment_eq(get_fs(), KERNEL_DS))) | ||
59 | |||
60 | extern int copy_from_user(void *to, const void __user *from, int n); | ||
61 | extern int copy_to_user(void __user *to, const void *from, int n); | ||
62 | |||
63 | /* | ||
64 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | ||
65 | * @dst: Destination address, in kernel space. This buffer must be at | ||
66 | * least @count bytes long. | ||
67 | * @src: Source address, in user space. | ||
68 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
69 | * | ||
70 | * Copies a NUL-terminated string from userspace to kernel space. | ||
71 | * | ||
72 | * On success, returns the length of the string (not including the trailing | ||
73 | * NUL). | ||
74 | * | ||
75 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
76 | * copied). | ||
77 | * | ||
78 | * If @count is smaller than the length of the string, copies @count bytes | ||
79 | * and returns @count. | ||
80 | */ | ||
81 | |||
82 | extern int strncpy_from_user(char *dst, const char __user *src, int count); | ||
83 | |||
84 | /* | ||
85 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
86 | * @to: Destination address, in user space. | ||
87 | * @n: Number of bytes to zero. | ||
88 | * | ||
89 | * Zero a block of memory in user space. Caller must check | ||
90 | * the specified block with access_ok() before calling this function. | ||
91 | * | ||
92 | * Returns number of bytes that could not be cleared. | ||
93 | * On success, this will be zero. | ||
94 | */ | ||
95 | extern int __clear_user(void __user *mem, int len); | ||
96 | |||
97 | /* | ||
98 | * clear_user: - Zero a block of memory in user space. | ||
99 | * @to: Destination address, in user space. | ||
100 | * @n: Number of bytes to zero. | ||
101 | * | ||
102 | * Zero a block of memory in user space. | ||
103 | * | ||
104 | * Returns number of bytes that could not be cleared. | ||
105 | * On success, this will be zero. | ||
106 | */ | ||
107 | extern int clear_user(void __user *mem, int len); | ||
108 | |||
109 | /* | ||
110 | * strlen_user: - Get the size of a string in user space. | ||
111 | * @str: The string to measure. | ||
112 | * @n: The maximum valid length | ||
113 | * | ||
114 | * Get the size of a NUL-terminated string in user space. | ||
115 | * | ||
116 | * Returns the size of the string INCLUDING the terminating NUL. | ||
117 | * On exception, returns 0. | ||
118 | * If the string is too long, returns a value greater than @n. | ||
119 | */ | ||
120 | extern int strnlen_user(const void __user *str, int len); | ||
42 | 121 | ||
43 | #define __copy_from_user(to, from, n) copy_from_user(to, from, n) | 122 | #define __copy_from_user(to, from, n) copy_from_user(to, from, n) |
44 | 123 | ||
diff --git a/arch/um/include/shared/um_uaccess.h b/arch/um/include/shared/um_uaccess.h deleted file mode 100644 index 51e1cce92d36..000000000000 --- a/arch/um/include/shared/um_uaccess.h +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __ARCH_UM_UACCESS_H | ||
7 | #define __ARCH_UM_UACCESS_H | ||
8 | |||
9 | #include <asm/elf.h> | ||
10 | #include <asm/fixmap.h> | ||
11 | #include "sysdep/archsetjmp.h" | ||
12 | |||
13 | #define __under_task_size(addr, size) \ | ||
14 | (((unsigned long) (addr) < TASK_SIZE) && \ | ||
15 | (((unsigned long) (addr) + (size)) < TASK_SIZE)) | ||
16 | |||
17 | #define __access_ok_vsyscall(type, addr, size) \ | ||
18 | ((type == VERIFY_READ) && \ | ||
19 | ((unsigned long) (addr) >= FIXADDR_USER_START) && \ | ||
20 | ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \ | ||
21 | ((unsigned long) (addr) + (size) >= (unsigned long)(addr))) | ||
22 | |||
23 | #define __addr_range_nowrap(addr, size) \ | ||
24 | ((unsigned long) (addr) <= ((unsigned long) (addr) + (size))) | ||
25 | |||
26 | #define access_ok(type, addr, size) \ | ||
27 | (__addr_range_nowrap(addr, size) && \ | ||
28 | (__under_task_size(addr, size) || \ | ||
29 | __access_ok_vsyscall(type, addr, size) || \ | ||
30 | segment_eq(get_fs(), KERNEL_DS))) | ||
31 | |||
32 | extern int copy_from_user(void *to, const void __user *from, int n); | ||
33 | extern int copy_to_user(void __user *to, const void *from, int n); | ||
34 | |||
35 | /* | ||
36 | * strncpy_from_user: - Copy a NUL terminated string from userspace. | ||
37 | * @dst: Destination address, in kernel space. This buffer must be at | ||
38 | * least @count bytes long. | ||
39 | * @src: Source address, in user space. | ||
40 | * @count: Maximum number of bytes to copy, including the trailing NUL. | ||
41 | * | ||
42 | * Copies a NUL-terminated string from userspace to kernel space. | ||
43 | * | ||
44 | * On success, returns the length of the string (not including the trailing | ||
45 | * NUL). | ||
46 | * | ||
47 | * If access to userspace fails, returns -EFAULT (some data may have been | ||
48 | * copied). | ||
49 | * | ||
50 | * If @count is smaller than the length of the string, copies @count bytes | ||
51 | * and returns @count. | ||
52 | */ | ||
53 | |||
54 | extern int strncpy_from_user(char *dst, const char __user *src, int count); | ||
55 | |||
56 | /* | ||
57 | * __clear_user: - Zero a block of memory in user space, with less checking. | ||
58 | * @to: Destination address, in user space. | ||
59 | * @n: Number of bytes to zero. | ||
60 | * | ||
61 | * Zero a block of memory in user space. Caller must check | ||
62 | * the specified block with access_ok() before calling this function. | ||
63 | * | ||
64 | * Returns number of bytes that could not be cleared. | ||
65 | * On success, this will be zero. | ||
66 | */ | ||
67 | extern int __clear_user(void __user *mem, int len); | ||
68 | |||
69 | /* | ||
70 | * clear_user: - Zero a block of memory in user space. | ||
71 | * @to: Destination address, in user space. | ||
72 | * @n: Number of bytes to zero. | ||
73 | * | ||
74 | * Zero a block of memory in user space. | ||
75 | * | ||
76 | * Returns number of bytes that could not be cleared. | ||
77 | * On success, this will be zero. | ||
78 | */ | ||
79 | extern int clear_user(void __user *mem, int len); | ||
80 | |||
81 | /* | ||
82 | * strlen_user: - Get the size of a string in user space. | ||
83 | * @str: The string to measure. | ||
84 | * @n: The maximum valid length | ||
85 | * | ||
86 | * Get the size of a NUL-terminated string in user space. | ||
87 | * | ||
88 | * Returns the size of the string INCLUDING the terminating NUL. | ||
89 | * On exception, returns 0. | ||
90 | * If the string is too long, returns a value greater than @n. | ||
91 | */ | ||
92 | extern int strnlen_user(const void __user *str, int len); | ||
93 | |||
94 | #endif | ||