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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 815B9C433DB for ; Fri, 12 Mar 2021 11:20:24 +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 1709364F6A for ; Fri, 12 Mar 2021 11:20:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1709364F6A 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=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:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hLktUDF4DF1l8sqe7FXIFz+2aXfPf5vJeYe25YzD+Fc=; b=IbQ094Fr1LL06R90Te5OxXmsC 7F9k7Ow3kZJszj16HjxIJZEpI/wrO2/WskXpwm77rBV3BAUl2cHCbUjYCXJtafvzv2m0E2a/PmeH0 LHMLIR5lP75WHhSlCa5d8W5Y+tZyCftIwQnS0qAX1KJLjMYkyOKhyfuCuDb0tRWUo4LUU6RTRFNih 21dA+Bddc9ysoHcq9EkVagriEWPAzAIIgC4z3Ih89MmzgnFErsL8RaGNIj92saJcUNZqvExT0r9JY OANrMOSwd7cER79o/U5HIIgYVBTapvIoG/cqyg8JBKqMJSnURbk/ZsrTxKAVWDXw4hnXRw1rKlQzJ o8hB3nUIw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKfoo-00BHGt-1T; Fri, 12 Mar 2021 11:18:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKfog-00BHFa-Sy for linux-arm-kernel@lists.infradead.org; Fri, 12 Mar 2021 11:18:52 +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 6CE5EED1; Fri, 12 Mar 2021 03:18:49 -0800 (PST) Received: from [10.57.15.100] (unknown [10.57.15.100]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2A8AF3F793; Fri, 12 Mar 2021 03:18:47 -0800 (PST) Subject: Re: [PATCH v3 1/2] arm64: Support execute-only permissions with Enhanced PAN To: Will Deacon , Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, keescook@chromium.org, dave.martin@arm.com 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> From: Vladimir Murzin Message-ID: <2424c35d-3e88-de1e-89b6-11439f1d15c6@arm.com> Date: Fri, 12 Mar 2021 11:19:02 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20210126122330.GA29613@willie-the-truck> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210312_111851_126925_DCD31AA8 X-CRM114-Status: GOOD ( 16.62 ) 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 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)) Cheers Vladimir _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel