From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73D04C433DF for ; Mon, 17 Aug 2020 16:03:22 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2208120748 for ; Mon, 17 Aug 2020 16:03:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2208120748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BVf3C3YHLzDqRL for ; Tue, 18 Aug 2020 02:03:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=93.17.236.30; helo=pegase1.c-s.fr; envelope-from=christophe.leroy@csgroup.eu; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BVdjn2wCtzDqVc for ; Tue, 18 Aug 2020 01:48:09 +1000 (AEST) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4BVdjS6XRmz9vCxl; Mon, 17 Aug 2020 17:47:56 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id HMNM4ubvFG_E; Mon, 17 Aug 2020 17:47:56 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4BVdjS5Vhfz9vCxf; Mon, 17 Aug 2020 17:47:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 35ED38B7C2; Mon, 17 Aug 2020 17:48:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id i100p36g_FZq; Mon, 17 Aug 2020 17:48:01 +0200 (CEST) Received: from [172.25.230.104] (po15451.idsi0.si.c-s.fr [172.25.230.104]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EA36D8B779; Mon, 17 Aug 2020 17:47:59 +0200 (CEST) Subject: Re: [PATCH 10/11] powerpc: use non-set_fs based maccess routines To: Christoph Hellwig , Al Viro , Michael Ellerman , x86@kernel.org References: <20200817073212.830069-1-hch@lst.de> <20200817073212.830069-11-hch@lst.de> From: Christophe Leroy Message-ID: <84df68bd-eb66-0105-1f3c-f3b07e5d60e6@csgroup.eu> Date: Mon, 17 Aug 2020 17:47:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200817073212.830069-11-hch@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Kees Cook , linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 17/08/2020 à 09:32, Christoph Hellwig a écrit : > Provide __get_kernel_nofault and __put_kernel_nofault routines to > implement the maccess routines without messing with set_fs and without > opening up access to user space. __get_user_size() opens access to user space. You have to use __get_user_size_allowed() when user access is already allowed (or when not needed to allow it). Christophe > > Signed-off-by: Christoph Hellwig > --- > arch/powerpc/include/asm/uaccess.h | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h > index 00699903f1efca..a31de40ac00b62 100644 > --- a/arch/powerpc/include/asm/uaccess.h > +++ b/arch/powerpc/include/asm/uaccess.h > @@ -623,4 +623,20 @@ do { \ > __put_user_goto(*(u8*)(_src + _i), (u8 __user *)(_dst + _i), e);\ > } while (0) > > +#define HAVE_GET_KERNEL_NOFAULT > + > +#define __get_kernel_nofault(dst, src, type, err_label) \ > +do { \ > + int __kr_err; \ > + \ > + __get_user_size(*((type *)(dst)), (__force type __user *)(src), \ > + sizeof(type), __kr_err); \ > + if (unlikely(__kr_err)) \ > + goto err_label; \ > +} while (0) > + > +#define __put_kernel_nofault(dst, src, type, err_label) \ > + __put_user_size_goto(*((type *)(src)), \ > + (__force type __user *)(dst), sizeof(type), err_label) > + > #endif /* _ARCH_POWERPC_UACCESS_H */ >