lib/usercopy: fix sparse errors
PATCH 1/1 lib/usercopy: fix sparse errors
CHECK lib/usercopy.clib/usercopy.c:26:13: warning: incorrect type in argument 1 (different address spaces)lib/usercopy.c:26:13: expected void const volatile [noderef] <asn:1>*<noident>lib/usercopy.c:26:13: got void *tolib/usercopy.c:27:34: warning: incorrect type in argument 1 (different address spaces)lib/usercopy.c:27:34: expected void const volatile *plib/usercopy.c:27:34: got void const [noderef] <asn:1>*fromlib/usercopy.c:28:38: warning: incorrect type in argument 1 (different address spaces)lib/usercopy.c:28:38: expected void [noderef] <asn:1>*tolib/usercopy.c:28:38: got void *tolib/usercopy.c:28:42: warning: incorrect type in argument 2 (different address spaces)lib/usercopy.c:28:42: expected void const *fromlib/usercopy.c:28:42: got void const [noderef] <asn:1>*fromlib/usercopy.c:23:15: error: symbol '_copy_to_user' redeclared with different type (originally declared at ./include/linux/uaccess.h:140) - incompatible argument 1 (different address spaces)
CC lib/usercopy.o
--- lib/usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/usercopy.c +1 -1
@@ -20,7 +20,7 @@ EXPORT_SYMBOL(_copy_from_user);#endif #ifndef INLINE_COPY_TO_USER -unsigned long _copy_to_user (void *to,const void __user *from,unsigned long n) +unsigned long _copy_to_user (void __user *to,const void *from,unsigned long n) {might_fault ();if (likely (access_ok (VERIFY_WRITE , to, n))) {
Signature · 6 lines
2.2.2 --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus
Quoted 28 lines · Christophe Leroy
CHECK
lib/usercopy.clib/usercopy.c:26:13: warning: incorrect type in argument 1 (different address spaces)lib/usercopy.c:26:13: expected void const volatile [noderef] <asn:1>*<noident>lib/usercopy.c:26:13: got void *tolib/usercopy.c:27:34: warning: incorrect type in argument 1 (different address spaces)lib/usercopy.c:27:34: expected void const volatile *plib/usercopy.c:27:34: got void const [noderef] <asn:1>*fromlib/usercopy.c:28:38: warning: incorrect type in argument 1 (different address spaces)lib/usercopy.c:28:38: expected void [noderef] <asn:1>*tolib/usercopy.c:28:38: got void *tolib/usercopy.c:28:42: warning: incorrect type in argument 2 (different address spaces)lib/usercopy.c:28:42: expected void const *fromlib/usercopy.c:28:42: got void const [noderef] <asn:1>*fromlib/usercopy.c:23:15: error: symbol '_copy_to_user' redeclared with different type (originally declared at./include/linux/uaccess.h:140) - incompatible argument 1 (different address spaces)
CClib/usercopy.oFixes d597580d37377 ("generic ...copy_..._user primitives")Signed-off-by Christophe Leroy <[email protected]>--- lib/usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/usercopy.c +0
-0
lib/usercopy.c EXPORT_SYMBOL(_copy_from_user); · line 26
Quoted 8 lines
lib/usercopy.c +1
-1@@ -20,7 +20,7 @@ EXPORT_SYMBOL(_copy_from_user);#endif #ifndef INLINE_COPY_TO_USER -unsigned long _copy_to_user (void *to,const void __user *from,unsigned long n) +unsigned long _copy_to_user (void __user *to,const void *from,unsigned long n) {might_fault ();if (likely (access_ok (VERIFY_WRITE , to, n))) {
Hi,
The change is good.
The commit message would better simply describe the problem instead of describing the symptom. For example, something like:
The function _copy_to_user() is used to copy to address space. As such, the destination pointer should be annotated with '__user'.
However, the function has the annotation wrongly, on the source instead of the destination (copy & paste error?). Fix this by moving the __user annotation to the correct argument.
-- Luc Van Oostenryck
Quoted 10 lines
The change is good.
The commit message would better simply describe the problem instead of describing the symptom. For example, something like:
The function_copy_to_user()is used to copy to address space. As such, the destination pointer should be annotated with '__user'.
However, the function has the annotation wrongly, on the source instead of the destination (copy & paste error?). Fix this by moving the__userannotation to the correct argument.
FWIW, I've committed it with
Fix misannotated out-of-line _copy_to_user()
Destination is a kernel pointer and source - a userland one is _copy_from_user(); _copy_to_user() is the other way round.