Received: by 2002:a05:6358:98a5:b0:11e:80f4:e92 with SMTP id q37csp23005rwa; Thu, 4 May 2023 13:47:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6n+eIKy/2mC3fq6eT2Ztmoj7juycWczD6qJwia0SNw1uBEqw7+VUnF/KLYdrVk/4Y32ynK X-Received: by 2002:a17:902:ec89:b0:1ab:515:27c3 with SMTP id x9-20020a170902ec8900b001ab051527c3mr5842599plg.47.1683233250071; Thu, 04 May 2023 13:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233250; cv=none; d=google.com; s=arc-20160816; b=pJyXeK97SFMdxskGzxRilrQZUByFHut8kXUlfgWtIEWD8Z8K4gkgCKFKH52OzLY2gi vc5262F6cDIBYV9sRsl/rJuZ4NzBLSHlb/rsNdTIZ6uOZfAXhCDpd+u2kp1X0HY3kIr2 8dKY7I0aZ7+NFZiU1AHf6+EOqGGQO6O+z3mv75c0r0bbnx9YgWiVfS5f8K/moviAfI0O dMLLi5JBaQVgO5A6i9SoFWop8EJUMoX0pAM5eu1OO04S7AXalkT4LVj8aRR52X0ZKNV6 Ak+IvrhZg8tJwKD62ELNybPHjIpT6qykU92Opljmsg4A57zhdiBY7YPv1Fi83F3zLne9 8yEQ== 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:dkim-signature; bh=m/qDBDw/nNJdwxgJ/b5PZHY5Zg9oYrRyxLosJRIIGco=; b=vXi/aXwLiqFXIaHGgS8qX9Ku9xmeEZPL46833IvlMKv6ycAVeeIDsiJTj8Ih3eeCAa CmJ3f7mgODzqHKvFalvHwW6nV4UskC9Z0v2dATdxjUk6WaPzWHm+KTON0UIGMwg+aUeh f0so5VokNWtWilmk3+c4sEFcCle8vzaRYdV73NWt477OfMyboCJN47FOuRnWvI6bel57 XX8VSC2gnHK+hVUpWvxxBR8r8XvD0sSKQJ2kUC1vHUMigk+mSZdaJAeSgpRqpOsrOJMd B6GeSqwtLuarJpPGfc/xN2Q87gfANhbxjLncPhGX6nzuGxWJTpksZh+8P13Hq9LPHJeJ felw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JLlqSzaO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a17090332ca00b001a6b273fef3si37924248plr.442.2023.05.04.13.47.17; Thu, 04 May 2023 13:47:30 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JLlqSzaO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbjEDUkR (ORCPT + 99 others); Thu, 4 May 2023 16:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbjEDUj0 (ORCPT ); Thu, 4 May 2023 16:39:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 592751943C for ; Thu, 4 May 2023 13:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683232302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=m/qDBDw/nNJdwxgJ/b5PZHY5Zg9oYrRyxLosJRIIGco=; b=JLlqSzaObAqgBpBrGZzMfBHCvkr8I/8l+EBvI4fGZea0YPwWcy6r4LUrenfcAvGE+bA4AW p19BTNs+TaO8PFrRkKiinW/H9g9O7JP02GSWMi+FZpMS74Tt1uBBAGU2v7kB8Ak1m7qbYk xyd/QpnnoWwUZxmMVSgVm1GIgE7sH04= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-VhIJEWHyOqGcb1qAgYOnjQ-1; Thu, 04 May 2023 16:06:35 -0400 X-MC-Unique: VhIJEWHyOqGcb1qAgYOnjQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-74faf5008bbso8080885a.0 for ; Thu, 04 May 2023 13:06:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683230795; x=1685822795; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=m/qDBDw/nNJdwxgJ/b5PZHY5Zg9oYrRyxLosJRIIGco=; b=D0rbwJ4C2zV5wGZ5FHkhXmRCBz6SZSeVvcDWUyKYX6ansFmCQzHWK7Qqgo/KCZZDju cQ69KguVL8J9TC8jK6ghVydUp0Fd8LqTH8VbSEJYayk3323tAqIrcysRfm16CKh92gjk zBnUotU3g4fIxcrWdfOazZ4KyM+7ubnOxKLf9FixJFK48dsSiaqq3FAp2RHoiuOZ7wMj vLaJFUr6tY3uDnMCGqAasZLPMdDplIZ9XkL6ATAkAsYhaQ4IxDHtMpk1JWqGgdGMd78x WWEa35UPRdefcNYeARgWK87NmBM8WEXIA4Py/dZovvRW5PQKomskRqEy4trdzLmYozkQ k5hw== X-Gm-Message-State: AC+VfDyGsfMzKUnQM/tZQoHtCTOxGafdIE0cvog5idlHChiD/xSzSTN+ a637GpeZH4pd+qBGn3FaWo5zrmpofV5w4zT25zjMqNqFPTx5WlfE74eW2FZCYbDsfZh5uQx5kxx 7p9CRQ04mreplORoH4PDyydrd X-Received: by 2002:a05:622a:1cb:b0:3f3:726a:6a70 with SMTP id t11-20020a05622a01cb00b003f3726a6a70mr2800144qtw.6.1683230794650; Thu, 04 May 2023 13:06:34 -0700 (PDT) X-Received: by 2002:a05:622a:1cb:b0:3f3:726a:6a70 with SMTP id t11-20020a05622a01cb00b003f3726a6a70mr2800119qtw.6.1683230794373; Thu, 04 May 2023 13:06:34 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id q3-20020ae9e403000000b0074df3f7e14esm39387qkc.67.2023.05.04.13.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 13:06:33 -0700 (PDT) Date: Thu, 4 May 2023 16:06:32 -0400 From: Peter Xu To: Florent Revest Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, catalin.marinas@arm.com, 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 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=utf-8 Content-Disposition: inline In-Reply-To: <20230504170942.822147-1-revest@chromium.org> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 Thu, May 04, 2023 at 07:09:38PM +0200, Florent Revest wrote: > Joey recently introduced a Memory-Deny-Write-Executable (MDWE) prctl which tags > current with a flag that prevents pages that were previously not executable from > becoming executable. > This tag always gets inherited by children tasks. (it's in MMF_INIT_MASK) > > At Google, we've been using a somewhat similar downstream patch for a few years > now. To make the adoption of this feature easier, we've had it support a mode in > which the W^X flag does not propagate to children. For example, this is handy if > a C process which wants W^X protection suspects it could start children > processes that would use a JIT. > > I'd like to align our features with the upstream prctl. This series proposes a > new NO_INHERIT flag to the MDWE prctl to make this kind of adoption easier. It > sets a different flag in current that is not in MMF_INIT_MASK and which does not > propagate. I don't think I have enough context, so sorry if I'm going to ask a naive question.. I can understand how current MDWE helps on not allowing any modifi-able content from becoming executable. How could NO_INHERIT help if it won't inherit and not in MMF_INIT_MASK? IIUC it means the restriction will only apply to the current process. Then I assume the process can escape from this rule simply by a fork(). If so, what's the point to protect at all? And, what's the difference of this comparing to disabling MDWE after being enabled (which seems to be forbidden for now, but it seems fork() can play a similar role of disabling it)? Thanks, -- Peter Xu