Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757378AbdLQRVp (ORCPT ); Sun, 17 Dec 2017 12:21:45 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40752 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbdLQRVo (ORCPT ); Sun, 17 Dec 2017 12:21:44 -0500 X-Google-Smtp-Source: ACJfBov29nmf/9DsO/3bxSNeHeR7PqhAGIn0/v55YVxQ3m0U3xH7UXxcs2Qu3iClKDlrkj8+lGiH0g== Date: Sun, 17 Dec 2017 18:21:40 +0100 From: Luc Van Oostenryck To: Christophe Leroy Cc: Al Viro , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib/usercopy: fix sparse errors Message-ID: <20171217172139.uytoormlzryy7pu5@ltop.local> References: <20171209162424.E5CEF41C4C@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171209162424.E5CEF41C4C@localhost.localdomain> User-Agent: NeoMutt/20171027 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2306 Lines: 53 On Sat, Dec 09, 2017 at 05:24:24PM +0100, Christophe Leroy wrote: > CHECK lib/usercopy.c > lib/usercopy.c:26:13: warning: incorrect type in argument 1 (different address spaces) > lib/usercopy.c:26:13: expected void const volatile [noderef] * > lib/usercopy.c:26:13: got void *to > lib/usercopy.c:27:34: warning: incorrect type in argument 1 (different address spaces) > lib/usercopy.c:27:34: expected void const volatile *p > lib/usercopy.c:27:34: got void const [noderef] *from > lib/usercopy.c:28:38: warning: incorrect type in argument 1 (different address spaces) > lib/usercopy.c:28:38: expected void [noderef] *to > lib/usercopy.c:28:38: got void *to > lib/usercopy.c:28:42: warning: incorrect type in argument 2 (different address spaces) > lib/usercopy.c:28:42: expected void const *from > lib/usercopy.c:28:42: got void const [noderef] *from > lib/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 > > Fixes: d597580d37377 ("generic ...copy_..._user primitives") > Signed-off-by: Christophe Leroy > --- > lib/usercopy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/usercopy.c b/lib/usercopy.c > index 15e2e6f..3744b2a 100644 > --- a/lib/usercopy.c > +++ b/lib/usercopy.c > @@ -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