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=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 5132BC63697 for ; Thu, 26 Nov 2020 18:45:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 ECA8221D1A for ; Thu, 26 Nov 2020 18:45:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KBWHeUOa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECA8221D1A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g9EMi6I6x+/FlSnYJg+jsA1Xk4ps6vTygzp2sXvIHg4=; b=KBWHeUOa1chnKnqFPZiqwdzWn 2t8I4THx0QhzMT78FEKS9EGlv81TWdn98/axhV5Bzf3dcIeKBU7Oq8ckJv2DWSUSypmgNcLh0aMuM Y6o8tGolgtSD6+7h7/RqI4z3RBMezhV7AEKCBI1kTPrmGykk/B0NXk8eniGvnMo+mpONe2w47wlpm euetgle4/IhbrASZFZBDPEFmIeyit/74ETHR+7jp8D9OT76QcPW7n6GXVhXeiGEBHXqU6ihbURV6w XfyLNlQ9g1UaHjvsc/uc9VRGBXUUPdoENW8vmjwPL147RUcMTdhiXAOjiiBS+JTsE36m+hSfUGPrS 463tLun0A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiMFL-0004f8-LK; Thu, 26 Nov 2020 18:43:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiME7-0004GF-K0 for linux-arm-kernel@lists.infradead.org; Thu, 26 Nov 2020 18:42:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F6591715; Thu, 26 Nov 2020 10:42:41 -0800 (PST) Received: from [172.16.1.114] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 224E33F23F; Thu, 26 Nov 2020 10:42:40 -0800 (PST) Subject: Re: [PATCHv4 12/17] arm64: uaccess: split user/kernel routines To: Mark Rutland , linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org References: <20201113124937.20574-1-mark.rutland@arm.com> <20201113124937.20574-13-mark.rutland@arm.com> From: James Morse Message-ID: <315fbabd-629d-e513-95f6-3d251f225779@arm.com> Date: Thu, 26 Nov 2020 18:42:24 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201113124937.20574-13-mark.rutland@arm.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201126_134243_840546_6B6818FC X-CRM114-Status: GOOD ( 20.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robin.murphy@arm.com, hch@lst.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Mark, On 13/11/2020 12:49, Mark Rutland wrote: > This patch separates arm64's user and kernel memory access primitives > into distinct routines, adding new __{get,put}_kernel_nofault() helpers > to acess kernel memory, upon which core code builds larger copy (access) > routines. > > The kernel access routines (using LDR/STR) are not affected by PAN (when > legitimately accessing kernel memory), nor are they affected by UAO. > Switching to KERNEL_DS may set UAO, but this does not adversely affect > the kernel access routines. > > The user access routines (using LDTR/STTR) are not affected by PAN (when > legitimately accessing user memory), but are affected by UAO. As these > are only legitimate to use under USER_DS with UAO clear, this should not > be problematic. > > Routines performing atomics to user memory (futex and deprecated > instruction emulation) still need to transiently clear PAN, and these > are left as-is. These are never used on kernel memory. > > Subsequent patches will refactor the uaccess helpers to remove redundant > code, and will also remove the redundant PAN/UAO manipulation. > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index 743f209d3fab..8687ec27dd00 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -253,10 +255,9 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr) > * The "__xxx_error" versions set the third argument to -EFAULT if an error > * occurs, and leave it unchanged on success. > */ > -#define __get_mem_asm(instr, alt_instr, reg, x, addr, err, feature) \ > +#define __get_mem_asm(ldr, reg, x, addr, err) \ ('ldr' as variable name where you need to output something other than ldr does my head in) > asm volatile( \ > - "1:"ALTERNATIVE(instr " " reg "1, [%2]\n", \ > - alt_instr " " reg "1, [%2]\n", feature) \ > + "1: " ldr " " reg "1, [%2]\n" \ > "2:\n" \ > " .section .fixup, \"ax\"\n" \ > " .align 2\n" \ > @@ -323,10 +320,19 @@ do { \ > > #define get_user __get_user > > -#define __put_mem_asm(instr, alt_instr, reg, x, addr, err, feature) \ > +#define __get_kernel_nofault(dst, src, type, err_label) \ > +do { \ > + int __gkn_err = 0; \ > + \ > + __raw_get_mem("ldr", *((type *)(dst)), \ > + (__force type __user *)(src), __gkn_err); \ Is the __user needed as you moved __chk_user_ptr() out of __raw_get_mem() in the previous patch? (your branch on kernel.org does something different here, not sure if its ahead or behind v4) > + if (unlikely(__gkn_err)) \ > + goto err_label; \ > +} while(0) Thanks, James _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel