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=-5.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 D36D8C433DB for ; Fri, 12 Mar 2021 11:22:05 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6C8A064F73 for ; Fri, 12 Mar 2021 11:22:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6C8A064F73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HfDrdonNGZR650bPdB/D7U7ROivG1qFfh+rm5+QhNhw=; b=ArOAhtexzpBpWO/Um+2vLDHIa L39ZDeWh07cU+/mCVc3i0sP4uH8hMi/+40JodsRjv8/CQP2rGq/b/WxjbDVAGJx9oaxi7p6z2xzmg CZOzg50j30iQyBn/5Sji1tf30/00BepmcsqzET8VwJzu+/cyLOkN40vne1IByugdww/moPe36kS5B EtibkEXuZVjtxHZvXJjcqrQkubijDXGieiXkuiQCRa0qGVjL/3gsRbCMfzryK4unuOuF5YZc6pKlG mMOTIeI338mroTyD7E3aQ7kw9WMRqzgjDPg/72sVDQNjrrl93Y8FJsdXtVlGUqrLhzrjA9Y3Dmqui hIKsNeCgA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKfqT-00BHZh-5k; Fri, 12 Mar 2021 11:20:41 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKfqO-00BHYa-9K for linux-arm-kernel@lists.infradead.org; Fri, 12 Mar 2021 11:20:38 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB28564F6A; Fri, 12 Mar 2021 11:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615548034; bh=HflgQe1C/MkfaBm43UXCS+wwxnXXGF5P00zNnRMB7nI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SsJ9HDBDKkGvJqlewLAhkOSLw9hz5cPnLQsjAhibK8Lx7rbA4sfzUptluyv6Iw391 0xlc0pLL2aJfkK2Z+4jE1o4r+nshm0qwouFrCwpiA9Cja/vE0KaTi/H6D5lvgRQ0Ch VD+PnkowcMliiDXmb8wUA43DbdiOPDyWJHv8FO9hh23+Qq0ucYXRNO8wsWwnuM/hhN 39wKaBgRd9Xg/Nf1FQcjURk0np7ysRYy57U6ujEaysy8H1ghhmagUMVxiYNTWvojdp N0DwHJ1AUyyQS4ALYfxG5sGu0ko6GXbI44Gyc3BRtJPO4KJCLbSVy4ev+Q+UMN0jhM QIQILAt+DOFUQ== Date: Fri, 12 Mar 2021 11:20:28 +0000 From: Will Deacon To: Vladimir Murzin Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, keescook@chromium.org, dave.martin@arm.com Subject: Re: [PATCH v3 1/2] arm64: Support execute-only permissions with Enhanced PAN Message-ID: <20210312112028.GC32208@willie-the-truck> References: <20210119160723.116983-1-vladimir.murzin@arm.com> <20210119160723.116983-2-vladimir.murzin@arm.com> <20210126110305.GA29467@willie-the-truck> <20210126120542.GA20158@gaia> <20210126122330.GA29613@willie-the-truck> <2424c35d-3e88-de1e-89b6-11439f1d15c6@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2424c35d-3e88-de1e-89b6-11439f1d15c6@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_112036_547825_EE8BF879 X-CRM114-Status: GOOD ( 19.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 On Fri, Mar 12, 2021 at 11:19:02AM +0000, Vladimir Murzin wrote: > On 1/26/21 12:23 PM, Will Deacon wrote: > > On Tue, Jan 26, 2021 at 12:05:42PM +0000, Catalin Marinas wrote: > >> On Tue, Jan 26, 2021 at 11:03:06AM +0000, Will Deacon wrote: > >>> On Tue, Jan 19, 2021 at 04:07:22PM +0000, Vladimir Murzin wrote: > >>>> #define pte_valid_not_user(pte) \ > >>>> - ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID) > >>>> + ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == (PTE_VALID | PTE_UXN)) > >>>> #define pte_valid_user(pte) \ > >>>> ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) > >>> > >>> Won't pte_valid_user() go wrong for exec-only mappings now? > >> > >> I wondered about the same in November (and reproducing my comment > >> below): > >> > >> https://lore.kernel.org/linux-arm-kernel/20201119182236.GN4376@gaia/ > >> > >> pte_valid_user() checks for both PTE_VALID and PTE_USER. In theory, a > >> !PTE_UXN is also user-accessible but it's only used in gup_pte_range() > >> via pte_access_permitted(). If "access" in the latter means only > >> read/write, we should be ok. If we keep it as is, a comment would > >> be useful. > > > > I think we should ensure that: > > > > pte_valid(pte) && (pte_valid_not_user(pte) || pte_valid_user(pte)) > > > > is always true, but I don't think it is after this patch. It reminds me > > of some of the tests that Anshuman wrote. > > Something like > > /* > * Most of user mappings would have PTE_USER bit set except Execute-only > * where both PTE_USER and PTE_UXN bits not set > */ > #define pte_valid_user(pte) \ > (((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) || \ > ((pte_val(pte) & (PTE_VALID | PTE_UXN)) == PTE_VALID)) Yeah, assuming the compiler doesn't make a dog's dinner of it. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel