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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 105B4C54791 for ; Wed, 13 Mar 2024 15:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=xx2KFOv0hDM7KufnEvwJW5TafHNqpfc9B2BOxR6KWPM=; b=4qveonCAkJGkCc 3KAktQBDcQhsfw0x/ZLyzbA5RVNABvUd6Y2kG9U5mTuhJrwa2SW8GnPwcYiPQe60kGEbiUt4KAmoO zEmH8J0murMCkufg4qvtRTFd7eRODQwOSS2DZn3IJxoni2Lyqx/PrlpjoTNozLGapCeaMVx9QbV9f GvbnPg+U8SNcMH/gYcT4X+RoDJqp3o6IgCQxQYnDROE4L8PYv6WIO65Z3TGr++05lcxCnA7qraJ9U ewtXBpZRDFhSuOKFnnyWnma8FzkqkWPJj+mJVP+1tK9UO1LfcDLxJzFa5UHDowts7j06b9Ol9GLyi tXMDIvEFLsbhAXaRjRJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkQZy-0000000AcFe-12Oc; Wed, 13 Mar 2024 15:31:42 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkQZs-0000000AcCL-3jGQ for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 15:31:40 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 42DE96148B; Wed, 13 Mar 2024 15:31:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 097F1C43609; Wed, 13 Mar 2024 15:31:32 +0000 (UTC) Date: Wed, 13 Mar 2024 15:31:30 +0000 From: Catalin Marinas To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook , Joey Gouly Subject: Re: [PATCH v8 42/43] mm: add arch hook to validate mmap() prot flags Message-ID: References: <20240214122845.2033971-45-ardb+git@google.com> <20240214122845.2033971-87-ardb+git@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_083137_528898_1F17F68F X-CRM114-Status: GOOD ( 26.84 ) 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 Wed, Mar 13, 2024 at 12:45:22PM +0100, Ard Biesheuvel wrote: > On Wed, 13 Mar 2024 at 11:47, Catalin Marinas wrote: > > However, I've been looking through specs and realised that SCTLR_ELx.WXN > > is RES0 when the permission indirection is enabled (FEAT_PIE from the > > 2022 specs, hopefully you have access to it). > > The latest public version of the ARM ARM does not cover FEAT_PIE at all. According to Mark R, the next version should be out soon. The xml tarball for the 2022 extensions doesn't have any new text for SCTLR_ELx.WXN field either. I could only find it in the engineering spec which isn't public: When Stage1 Base Permissions uses the Indirect Permission Scheme, SCTLR_ELx.WXN has no effect and is RES 0. > > And while apparently WXN > > gets better as it allows separate EL0/EL1 controls, it seems to only > > apply when the base permission is RWX and the XN is toggled based on the > > overlay permission (pkeys which Joey is working on). So it looks like > > what the architects had in mind is optimising RW/RX switching via > > overlays (no syscalls) but keeping the base permission RWX. The > > traditional WXN hardening via SCTLR_EL1 disappeared. > > > > (adding Joey to the thread, he contributed the PIE support) > > PIE sounds useful to implement things like JITs in user space, where > you want a certain mapping to transition to RW while all other CPUs > retain RX access concurrently. > > WXN is intended to be static, where a single bit sets the system-wide > policy for all kernel and user space code. I agree. I guess no-one used the current WXN and the architects decided to deprecate it. > It's rather unfortunate that FEAT_PIE relies on RWX mappings and > therefore needs to deprecate WXN entirely. It would have been nice to > have something like this for the kernel, which never has a need for > RWX mappings or transitioning mappings between RX and RW like that, > and so overlays don't seem to be a great fit. Indeed. It looks more of a risk to somehow use WXN in the kernel in combination with overlays because of the RWX permission. > I looked into this a bit more, and MDWE is a bit stricter than WXN, > and therefore less suitable for enabling system-wide. It disallows > adding executable permissions entirely, as well as adding write > permissions to a mapping that is already executable. WXN just > disallows setting both at the same time. With MDWE, we tried to copy the semantics of the BPF variant. It allows mmap(PROT_EXEC) but not mrpotect(PROT_EXEC). But I agree, it's slightly different than your proposed WXN. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel