Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5566435rwr; Tue, 9 May 2023 03:24:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7at1wksY0gXS0D9hkveRLrUhQ/l9ywU0vGn08J+QjqEr05Gdoq/VVdpb1nNEzzQ9KsmOxL X-Received: by 2002:a05:6a00:2401:b0:63d:3339:e967 with SMTP id z1-20020a056a00240100b0063d3339e967mr16565633pfh.19.1683627892610; Tue, 09 May 2023 03:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683627892; cv=none; d=google.com; s=arc-20160816; b=Bx2IbUcFnzAMZ6LqQ7SubkrURhzbYrwjEOxSWv1AQ6kYkPgeM+nkDYT3OLvVfYmks/ Z/bqgpCJJ3koA72I52hGWEH0eQtflrkMo7LNuet8BqyL77OJJ2FRkDNYaZRrXLQpqZxo EeOgccTMUtyUfbnA4Mxzz96QgX72oMpHb1UKysnxC3SKlDxdfRtzvsRKHVQoko0qFtZT /S0PNzPebuCjflYFqVPCL0+F/UyTe8ISa6PDf/jw3QcuhaZRf8GC+y/x2fXiNbDFB5yX RJzka3t2XvN1oEKIe11RXpb99X1bi5o2+lK4amfHFelwNuKzkOpfqv6qeLgR1KYmHoZ0 pybw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=P6/fVm0gBSXnKKUtLnBjT7+4yr2kMJOD2poA0u1zYW8=; b=xTr4aXbnnzrVadcb1m3tZFYnQnXwUnwDukKhhMu6xbp4CU7S3fN8ZUjR7DsO5LU4II wlmM5ZOk/Hq8C2H/3EnD1OnN+6hjx58Ognj+9xFRYU8Vi+Nh3OfcgALxjb2LLoSgKHFd ROQAJA0IiMjZmwi6trzLjSTfgKMDt8fS5PGVwJmPl9lPJn3RlFBybBFz+lFZNlist0QO FXtN4UO7+LIyMO8Wf9Iz9NANzCj5gD77jslh3YPZjF6pP42fkpOCEiSFHEnzwTxadII/ okfL1bz4EBKxF4oudoE6mxqVXUDoCcuv8Atjo27kCBEyeoDAHlmDt7m1u2/GADTsP9r5 UZeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020aa796c4000000b00646479e5702si2070383pfq.381.2023.05.09.03.24.40; Tue, 09 May 2023 03:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235087AbjEIKEe (ORCPT + 99 others); Tue, 9 May 2023 06:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234848AbjEIKE1 (ORCPT ); Tue, 9 May 2023 06:04:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D94246BD for ; Tue, 9 May 2023 03:04:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ED14E62296 for ; Tue, 9 May 2023 10:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82BDFC433D2; Tue, 9 May 2023 10:04:21 +0000 (UTC) Date: Tue, 9 May 2023 11:04:18 +0100 From: Catalin Marinas To: Topi Miettinen Cc: Florent Revest , Peter Xu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, anshuman.khandual@arm.com, joey.gouly@arm.com, mhocko@suse.com, keescook@chromium.org, david@redhat.com, izbyshev@ispras.ru, nd@arm.com, broonie@kernel.org, szabolcs.nagy@arm.com, lennart@poettering.net Subject: Re: [PATCH 0/4] MDWE without inheritance Message-ID: References: <20230504170942.822147-1-revest@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 08, 2023 at 08:21:16PM +0300, Topi Miettinen wrote: > On 8.5.2023 17.10, Catalin Marinas wrote: > > I think we should keep the original behaviour of systemd here, otherwise > > they won't transition to the new interface and keep using the SECCOMP > > BPF approach (which, in addition, prevents glibc from setting PROT_BTI > > on an already executable mapping). > > Systemd has transitioned to prctl(PR_SET_MDWE) method since release of v253, > so the original behaviour definitely should be kept. That's great. So yes, no ABI changes allowed anymore. > > x86 has protection keys and arm64 will soon have permission overlays > > that allow user-space to toggle between RX and RW (Joey is looking at > > the arm64 support). I'm not sure how we'll end up implemented this on > > arm64 (and haven't looked at x86) but I have a suspicion MDWE will get > > in the way as the base page table permission will probably need > > PROT_WRITE|PROT_EXEC. > > Wouldn't those features defeat any gains from MDWE? The features probably > should be forbidden with MemoryDenyWriteExecute=yes. The permission overlays (controlled by the user) can only further restrict the mmap() permissions. So MDWE would still work as expected. If one wants to toggle between RW and RX with overlays, the overall mmap() needs to be RWX and it won't work if MDWE=yes. No need to explicitly disable the overlays feature. On arm64 at least, with the introduction of permission overlays we also have the notion of "Read, Execute if not Write". This permission automatically disables Exec if the mapping becomes writable (overlays can disable writable, allowing exec). We could have a new MDWE policy which allows this, though I'm not that keen on using it in Linux since background permission changes done by the kernel can lead to an unexpected executable permission (e.g. marking a page read-only for clean/dirty tracking or in preparation for CoW after fork()). -- Catalin