diff options
Diffstat (limited to 'arch/x86/include/asm/uaccess_64.h')
-rw-r--r-- | arch/x86/include/asm/uaccess_64.h | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h index 4f7923dd0007..190413d0de57 100644 --- a/arch/x86/include/asm/uaccess_64.h +++ b/arch/x86/include/asm/uaccess_64.h | |||
@@ -46,42 +46,13 @@ copy_user_generic(void *to, const void *from, unsigned len) | |||
46 | } | 46 | } |
47 | 47 | ||
48 | __must_check unsigned long | 48 | __must_check unsigned long |
49 | _copy_to_user(void __user *to, const void *from, unsigned len); | ||
50 | __must_check unsigned long | ||
51 | _copy_from_user(void *to, const void __user *from, unsigned len); | ||
52 | __must_check unsigned long | ||
53 | copy_in_user(void __user *to, const void __user *from, unsigned len); | 49 | copy_in_user(void __user *to, const void __user *from, unsigned len); |
54 | 50 | ||
55 | static inline unsigned long __must_check copy_from_user(void *to, | ||
56 | const void __user *from, | ||
57 | unsigned long n) | ||
58 | { | ||
59 | int sz = __compiletime_object_size(to); | ||
60 | |||
61 | might_fault(); | ||
62 | if (likely(sz == -1 || sz >= n)) | ||
63 | n = _copy_from_user(to, from, n); | ||
64 | #ifdef CONFIG_DEBUG_VM | ||
65 | else | ||
66 | WARN(1, "Buffer overflow detected!\n"); | ||
67 | #endif | ||
68 | return n; | ||
69 | } | ||
70 | |||
71 | static __always_inline __must_check | 51 | static __always_inline __must_check |
72 | int copy_to_user(void __user *dst, const void *src, unsigned size) | 52 | int __copy_from_user_nocheck(void *dst, const void __user *src, unsigned size) |
73 | { | ||
74 | might_fault(); | ||
75 | |||
76 | return _copy_to_user(dst, src, size); | ||
77 | } | ||
78 | |||
79 | static __always_inline __must_check | ||
80 | int __copy_from_user(void *dst, const void __user *src, unsigned size) | ||
81 | { | 53 | { |
82 | int ret = 0; | 54 | int ret = 0; |
83 | 55 | ||
84 | might_fault(); | ||
85 | if (!__builtin_constant_p(size)) | 56 | if (!__builtin_constant_p(size)) |
86 | return copy_user_generic(dst, (__force void *)src, size); | 57 | return copy_user_generic(dst, (__force void *)src, size); |
87 | switch (size) { | 58 | switch (size) { |
@@ -121,11 +92,17 @@ int __copy_from_user(void *dst, const void __user *src, unsigned size) | |||
121 | } | 92 | } |
122 | 93 | ||
123 | static __always_inline __must_check | 94 | static __always_inline __must_check |
124 | int __copy_to_user(void __user *dst, const void *src, unsigned size) | 95 | int __copy_from_user(void *dst, const void __user *src, unsigned size) |
96 | { | ||
97 | might_fault(); | ||
98 | return __copy_from_user_nocheck(dst, src, size); | ||
99 | } | ||
100 | |||
101 | static __always_inline __must_check | ||
102 | int __copy_to_user_nocheck(void __user *dst, const void *src, unsigned size) | ||
125 | { | 103 | { |
126 | int ret = 0; | 104 | int ret = 0; |
127 | 105 | ||
128 | might_fault(); | ||
129 | if (!__builtin_constant_p(size)) | 106 | if (!__builtin_constant_p(size)) |
130 | return copy_user_generic((__force void *)dst, src, size); | 107 | return copy_user_generic((__force void *)dst, src, size); |
131 | switch (size) { | 108 | switch (size) { |
@@ -165,6 +142,13 @@ int __copy_to_user(void __user *dst, const void *src, unsigned size) | |||
165 | } | 142 | } |
166 | 143 | ||
167 | static __always_inline __must_check | 144 | static __always_inline __must_check |
145 | int __copy_to_user(void __user *dst, const void *src, unsigned size) | ||
146 | { | ||
147 | might_fault(); | ||
148 | return __copy_to_user_nocheck(dst, src, size); | ||
149 | } | ||
150 | |||
151 | static __always_inline __must_check | ||
168 | int __copy_in_user(void __user *dst, const void __user *src, unsigned size) | 152 | int __copy_in_user(void __user *dst, const void __user *src, unsigned size) |
169 | { | 153 | { |
170 | int ret = 0; | 154 | int ret = 0; |
@@ -220,13 +204,13 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size) | |||
220 | static __must_check __always_inline int | 204 | static __must_check __always_inline int |
221 | __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size) | 205 | __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size) |
222 | { | 206 | { |
223 | return copy_user_generic(dst, (__force const void *)src, size); | 207 | return __copy_from_user_nocheck(dst, (__force const void *)src, size); |
224 | } | 208 | } |
225 | 209 | ||
226 | static __must_check __always_inline int | 210 | static __must_check __always_inline int |
227 | __copy_to_user_inatomic(void __user *dst, const void *src, unsigned size) | 211 | __copy_to_user_inatomic(void __user *dst, const void *src, unsigned size) |
228 | { | 212 | { |
229 | return copy_user_generic((__force void *)dst, src, size); | 213 | return __copy_to_user_nocheck((__force void *)dst, src, size); |
230 | } | 214 | } |
231 | 215 | ||
232 | extern long __copy_user_nocache(void *dst, const void __user *src, | 216 | extern long __copy_user_nocache(void *dst, const void __user *src, |