Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sparc: Kill user copy check code.

For whatever reason GCC isn't able to figure things out in
the control flow (in particular when min() and max() expressions
are involved) on sparc as well as it can on x86.

So lots of useless incorrect user copy warnings get spewed and the
full-on compile failure mode of the user copy checks were never usable
on sparc at all.

People can debug these kinds of problems on x86.

Signed-off-by: David S. Miller <davem@davemloft.net>

+4 -46
-14
arch/sparc/Kconfig.debug
··· 30 30 depends on MCOUNT 31 31 default y 32 32 33 - config 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 - 47 33 endmenu
-15
arch/sparc/include/asm/uaccess_32.h
··· 260 260 return __copy_user(to, (__force void __user *) from, n); 261 261 } 262 262 263 - extern 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 - 271 263 static 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 265 if (n && __access_ok((unsigned long) from, n)) 281 266 return __copy_user((__force void __user *) to, from, n); 282 267 else
+4 -17
arch/sparc/include/asm/uaccess_64.h
··· 205 205 206 206 extern int __get_user_bad(void); 207 207 208 - extern 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 - 216 208 extern unsigned long __must_check ___copy_from_user(void *to, 217 209 const void __user *from, 218 210 unsigned long size); ··· 213 221 static inline unsigned long __must_check 214 222 copy_from_user(void *to, const void __user *from, unsigned long size) 215 223 { 216 - int sz = __compiletime_object_size(to); 217 - unsigned long ret = size; 224 + unsigned long ret = ___copy_from_user(to, from, size); 218 225 219 - if (likely(sz == -1 || sz >= size)) { 220 - ret = ___copy_from_user(to, from, size); 221 - if (unlikely(ret)) 222 - ret = copy_from_user_fixup(to, from, size); 223 - } else { 224 - copy_from_user_overflow(); 225 - } 226 + if (unlikely(ret)) 227 + ret = copy_from_user_fixup(to, from, size); 228 + 226 229 return ret; 227 230 } 228 231 #define __copy_from_user copy_from_user