Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3938481imm; Mon, 4 Jun 2018 11:48:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLhMOxSuUZMP96jJRZH4lhUqGgJizqvovN/EaXfKGd7YO67aBAM4Cszq7bll6ccgwxJUtQo X-Received: by 2002:aa7:80c6:: with SMTP id a6-v6mr22278171pfn.120.1528138113902; Mon, 04 Jun 2018 11:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528138113; cv=none; d=google.com; s=arc-20160816; b=pUQ6nk2IWwYfgNSTnlVzqPiMjb4WBNU2TUYXh5xIXBWsxFitMVeGVtX9kKVbPqwRDc 3bmUulkItFskbcEsioMkrWjm7fPYOfdQw/kFsNkzG2VmeaNxBNaMB3a0+L9UgS388lYS xEU5ZKqLk/VSjQOLx7jwMm1jpLK2zjVF2vt+RsBboMWvfvDCdS8sImZQzCfKFNa4CgPh Pb+LJy8LsI5JUto5szTCRIUZ80RvLRCRwnFE2VArtiFDqJM8ZaF4xfkN5fwiL4OrZnu1 Xn1knsyBujr1+F2RHG+yBbFAJPADr9vNwnLZTIPxvyrQ6k3Y4w5UyYsL9kab+hRBGh3y mJ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=oBuws6P5Rk2ehChSYbXidPx1BKSfnuvqD/I7eStrZ1o=; b=0Y7zNgHjcYB2yfL9zHM8UgF+rwyn+NIKBmJ/15gwJb4MH4qweK9QYHB14nbtgKAm1M e7B+s1kduK9Dh2Gx5DMiVFj49+I9xANKsPJjEFP8r8jxHhwMstxuvrJmcCtogGqoNqSv 7fx5MCRz0TZE5VncG1OxMkROQRE0KYxd4INYZcZJHOaJWj2V7sl1nYSq67s8/4GzMr+Q Qyb+E1LYOijj14ZiXBzF0HPuaJbEpzPjHYrx9htyMs210KR4yMlIDKKQr0ik8+A7ARBK r/5gqJasQh7ERJ6rlNBy2vK/8YSnrJrfE7WAeCpPYo6d622prNvZUVvNdmeA1oWUAJts l15g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dcSGGE1V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35-v6si12970573pla.543.2018.06.04.11.48.09; Mon, 04 Jun 2018 11:48:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dcSGGE1V; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751284AbeFDSqw (ORCPT + 99 others); Mon, 4 Jun 2018 14:46:52 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:24887 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbeFDSqv (ORCPT ); Mon, 4 Jun 2018 14:46:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1528138533; x=1559674533; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=cvizIsQuC4oF4MoF3ul65SG5yAxeISJnKOi3H6P2/zo=; b=dcSGGE1VqXB2qa0fFO9edijKM5uBTofQh4ehr88DPcTWwkhKOvZcU1zj RP1oTJcYC1FiUwFq0D7KSUNKTOYow9Xc9yhPGPgISvDiOSOhiqi8uQPLi zmV3oYLTO1wUBq/Gxa85y/jji6ME2HcS/U8F7yqr8DnLkFpmrHar+7btP FYAJZS4sq6P78ssIUr0/c6YiE8qUde7ESOrCOncpxMAzY+o1QuPAMFxVa bfdopKDUhbfTLK6B33U3KSEak8836IjiWIBtXmpkaHvy+Va2XwCgtv8gb 4KfI5tjXtMIbKbEPrXfqlESiF3EVDX1mvNzSHPjlzDt6hpt17UgqVYjOM Q==; X-IronPort-AV: E=Sophos;i="5.49,476,1520870400"; d="scan'208";a="176488093" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 05 Jun 2018 02:55:32 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 04 Jun 2018 11:37:24 -0700 Received: from c02v91rdhtd5.sdcorp.global.sandisk.com (HELO [10.196.157.210]) ([10.196.157.210]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Jun 2018 11:46:51 -0700 Subject: Re: [PATCH 3/3] riscv: fix __user annotation for __copy_user() To: Luc Van Oostenryck , Palmer Dabbelt Cc: "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Albert Ou References: <20180601152123.47256-1-luc.vanoostenryck@gmail.com> <20180601152123.47256-4-luc.vanoostenryck@gmail.com> From: Atish Patra Message-ID: <235fec3e-be2e-874a-8313-e7390fcdca74@wdc.com> Date: Mon, 4 Jun 2018 11:46:50 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180601152123.47256-4-luc.vanoostenryck@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/1/18 8:22 AM, Luc Van Oostenryck wrote: > __copy_user() is a function, written in assembly, used to copy > memory between kernel & user space. As such its to & from args > may both take a user pointer or a kernel pointer. > > However the prototype for this function declare these two args > as 'void __user *', which is no more & no less correct than > declaring them as 'void *'. In fact theer is no possible correct /s/theer/there > annotation for such a function. > > The problem is worked around here by declaring these args as > unsigned long and casting them to the right type in each of > two callers raw_copy_{to,from}_user() as some kind of cast would > be needed anyway. > > Note: another solution, maybe cleaner but slightly more complex, > would be to declare two version of __copy_user, > either in the asm file or via an alias, each having already > the correct typing for raw_copy_{to,from}_user(). > I feel that would be a better solution as it is implemented similarly in ARM as well. I am unable to understand how "unsigned long" is better than "void*". x86 implementation has both arguments as void*. Can you please clarify ? Regards, Atish > Signed-off-by: Luc Van Oostenryck > --- > arch/riscv/include/asm/uaccess.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h > index 14b0b22fb..c7a6a4a4a 100644 > --- a/arch/riscv/include/asm/uaccess.h > +++ b/arch/riscv/include/asm/uaccess.h > @@ -392,19 +392,19 @@ do { \ > }) > > > -extern unsigned long __must_check __copy_user(void __user *to, > - const void __user *from, unsigned long n); > +extern unsigned long __must_check __copy_user(unsigned long to, > + const unsigned long from, unsigned long n); > > static inline unsigned long > raw_copy_from_user(void *to, const void __user *from, unsigned long n) > { > - return __copy_user(to, from, n); > + return __copy_user((unsigned long)to, (unsigned long)from, n); > } > > static inline unsigned long > raw_copy_to_user(void __user *to, const void *from, unsigned long n) > { > - return __copy_user(to, from, n); > + return __copy_user((unsigned long)to, (unsigned long)from, n); > } > > extern long strncpy_from_user(char *dest, const char __user *src, long count); >