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

cris: correct usage of __user for copy to and from user space in lib/usercopy and uaccess.h

Function __copy_user_zeroing in arch/lib/usercopy.c had the wrong parameter
set as __user, and in include/asm-cris/uaccess.h, it was not set at all for
some of the calling functions.

This will cut the number of warnings quite dramatically when using sparse.

While we're here, remove useless CVS log and correct confusing typo.

Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Mikael Starvik <mikael.starvik@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jesper Nilsson and committed by
Linus Torvalds
07f2402b cee47f5a

+11 -46
+1 -1
arch/cris/arch-v10/lib/usercopy.c
··· 193 193 inaccessible. */ 194 194 195 195 unsigned long 196 - __copy_user_zeroing (void __user *pdst, const void *psrc, unsigned long pn) 196 + __copy_user_zeroing(void *pdst, const void __user *psrc, unsigned long pn) 197 197 { 198 198 /* We want the parameters put in special registers. 199 199 Make sure the compiler is able to make something useful of this.
+1 -1
arch/cris/arch-v32/lib/usercopy.c
··· 161 161 inaccessible. */ 162 162 163 163 unsigned long 164 - __copy_user_zeroing (void __user *pdst, const void *psrc, unsigned long pn) 164 + __copy_user_zeroing(void *pdst, const void __user *psrc, unsigned long pn) 165 165 { 166 166 /* We want the parameters put in special registers. 167 167 Make sure the compiler is able to make something useful of this.
+9 -44
include/asm-cris/uaccess.h
··· 1 1 /* 2 2 * Authors: Bjorn Wesen (bjornw@axis.com) 3 3 * Hans-Peter Nilsson (hp@axis.com) 4 - * 5 - * $Log: uaccess.h,v $ 6 - * Revision 1.8 2001/10/29 13:01:48 bjornw 7 - * Removed unused variable tmp2 in strnlen_user 8 - * 9 - * Revision 1.7 2001/10/02 12:44:52 hp 10 - * Add support for 64-bit put_user/get_user 11 - * 12 - * Revision 1.6 2001/10/01 14:51:17 bjornw 13 - * Added register prefixes and removed underscores 14 - * 15 - * Revision 1.5 2000/10/25 03:33:21 hp 16 - * - Provide implementation for everything else but get_user and put_user; 17 - * copying inline to/from user for constant length 0..16, 20, 24, and 18 - * clearing for 0..4, 8, 12, 16, 20, 24, strncpy_from_user and strnlen_user 19 - * always inline. 20 - * - Constraints for destination addr in get_user cannot be memory, only reg. 21 - * - Correct labels for PC at expected fault points. 22 - * - Nits with assembly code. 23 - * - Don't use statement expressions without value; use "do {} while (0)". 24 - * - Return correct values from __generic_... functions. 25 - * 26 - * Revision 1.4 2000/09/12 16:28:25 bjornw 27 - * * Removed comments from the get/put user asm code 28 - * * Constrains for destination addr in put_user cannot be memory, only reg 29 - * 30 - * Revision 1.3 2000/09/12 14:30:20 bjornw 31 - * MAX_ADDR_USER does not exist anymore 32 - * 33 - * Revision 1.2 2000/07/13 15:52:48 bjornw 34 - * New user-access functions 35 - * 36 - * Revision 1.1.1.1 2000/07/10 16:32:31 bjornw 37 - * CRIS architecture, working draft 38 - * 39 - * 40 - * 41 4 */ 42 5 43 6 /* Asm:s have been tweaked (within the domain of correctness) to give ··· 172 209 /* More complex functions. Most are inline, but some call functions that 173 210 live in lib/usercopy.c */ 174 211 175 - extern unsigned long __copy_user(void *to, const void *from, unsigned long n); 176 - extern unsigned long __copy_user_zeroing(void *to, const void *from, unsigned long n); 177 - extern unsigned long __do_clear_user(void *to, unsigned long n); 212 + extern unsigned long __copy_user(void __user *to, const void *from, unsigned long n); 213 + extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n); 214 + extern unsigned long __do_clear_user(void __user *to, unsigned long n); 178 215 179 216 static inline unsigned long 180 217 __generic_copy_to_user(void __user *to, const void *from, unsigned long n) ··· 216 253 } 217 254 218 255 219 - /* Note that if these expand awfully if made into switch constructs, so 256 + /* Note that these expand awfully if made into switch constructs, so 220 257 don't do that. */ 221 258 222 259 static inline unsigned long ··· 370 407 */ 371 408 372 409 static inline unsigned long 373 - __generic_copy_from_user_nocheck(void *to, const void *from, unsigned long n) 410 + __generic_copy_from_user_nocheck(void *to, const void __user *from, 411 + unsigned long n) 374 412 { 375 413 return __copy_user_zeroing(to,from,n); 376 414 } 377 415 378 416 static inline unsigned long 379 - __generic_copy_to_user_nocheck(void *to, const void *from, unsigned long n) 417 + __generic_copy_to_user_nocheck(void __user *to, const void *from, 418 + unsigned long n) 380 419 { 381 420 return __copy_user(to,from,n); 382 421 } 383 422 384 423 static inline unsigned long 385 - __generic_clear_user_nocheck(void *to, unsigned long n) 424 + __generic_clear_user_nocheck(void __user *to, unsigned long n) 386 425 { 387 426 return __do_clear_user(to,n); 388 427 }