aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sparc/Kconfig.debug14
-rw-r--r--arch/sparc/include/asm/uaccess_32.h15
-rw-r--r--arch/sparc/include/asm/uaccess_64.h23
3 files changed, 5 insertions, 47 deletions
diff --git a/arch/sparc/Kconfig.debug b/arch/sparc/Kconfig.debug
index 1b4a831565f9..d9a795efbc04 100644
--- a/arch/sparc/Kconfig.debug
+++ b/arch/sparc/Kconfig.debug
@@ -30,18 +30,4 @@ config FRAME_POINTER
30 depends on MCOUNT 30 depends on MCOUNT
31 default y 31 default y
32 32
33config DEBUG_STRICT_USER_COPY_CHECKS
34 bool "Strict copy size checks"
35 depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
36 ---help---
37 Enabling this option turns a certain set of sanity checks for user
38 copy operations into compile time failures.
39
40 The copy_from_user() etc checks are there to help test if there
41 are sufficient security checks on the length argument of
42 the copy operation, by having gcc prove that the argument is
43 within bounds.
44
45 If unsure, or if you run an older (pre 4.4) gcc, say N.
46
47endmenu 33endmenu
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 25f1d10155e8..8303ac481034 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -260,23 +260,8 @@ static inline unsigned long __copy_to_user(void __user *to, const void *from, un
260 return __copy_user(to, (__force void __user *) from, n); 260 return __copy_user(to, (__force void __user *) from, n);
261} 261}
262 262
263extern void copy_from_user_overflow(void)
264#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
265 __compiletime_error("copy_from_user() buffer size is not provably correct")
266#else
267 __compiletime_warning("copy_from_user() buffer size is not provably correct")
268#endif
269;
270
271static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n) 263static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
272{ 264{
273 int sz = __compiletime_object_size(to);
274
275 if (unlikely(sz != -1 && sz < n)) {
276 copy_from_user_overflow();
277 return n;
278 }
279
280 if (n && __access_ok((unsigned long) from, n)) 265 if (n && __access_ok((unsigned long) from, n))
281 return __copy_user((__force void __user *) to, from, n); 266 return __copy_user((__force void __user *) to, from, n);
282 else 267 else
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index 2406788bfe5f..3e1449f07798 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -205,14 +205,6 @@ __asm__ __volatile__( \
205 205
206extern int __get_user_bad(void); 206extern int __get_user_bad(void);
207 207
208extern void copy_from_user_overflow(void)
209#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
210 __compiletime_error("copy_from_user() buffer size is not provably correct")
211#else
212 __compiletime_warning("copy_from_user() buffer size is not provably correct")
213#endif
214;
215
216extern unsigned long __must_check ___copy_from_user(void *to, 208extern unsigned long __must_check ___copy_from_user(void *to,
217 const void __user *from, 209 const void __user *from,
218 unsigned long size); 210 unsigned long size);
@@ -221,16 +213,11 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
221static inline unsigned long __must_check 213static inline unsigned long __must_check
222copy_from_user(void *to, const void __user *from, unsigned long size) 214copy_from_user(void *to, const void __user *from, unsigned long size)
223{ 215{
224 int sz = __compiletime_object_size(to); 216 unsigned long ret = ___copy_from_user(to, from, size);
225 unsigned long ret = size; 217
226 218 if (unlikely(ret))
227 if (likely(sz == -1 || sz >= size)) { 219 ret = copy_from_user_fixup(to, from, size);
228 ret = ___copy_from_user(to, from, size); 220
229 if (unlikely(ret))
230 ret = copy_from_user_fixup(to, from, size);
231 } else {
232 copy_from_user_overflow();
233 }
234 return ret; 221 return ret;
235} 222}
236#define __copy_from_user copy_from_user 223#define __copy_from_user copy_from_user