Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21690343rwd; Thu, 29 Jun 2023 21:08:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2tIbWRiKoVtGt23xzuhKv36f0M4d2LoogC+TT+gb4QavdBwy4AB/9GXv5JsIuqUL5CcwV X-Received: by 2002:a05:6214:2401:b0:635:feb0:843b with SMTP id fv1-20020a056214240100b00635feb0843bmr2218573qvb.51.1688098080164; Thu, 29 Jun 2023 21:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688098080; cv=none; d=google.com; s=arc-20160816; b=YawU5h/OdFjr3HPph4D31bhfGBspuw+s8gRsSKpijrH4wwwFsdYBW1h96v/ZPCs7cX YVmt9iYGRfd3MZQ8I6kOMhkQ4Dgb0M8wfFd5M3AcVhsUZMtauwAdHgQKfrIDWReJya+0 jGXt/firtKlKWaE+6/ZPtYugiryj0HhsrZDMBxvTtIL0iUehCZzmmvGcDZsqcuRsVvQ2 yyo72TBrjW18USneg6N/Oaja+Xnb9VT4k42IG/dtSptlcnBpGP+VZvSZJHa7D05FlZiy +duPEqqWVi+rOYzO0wJmr8DSos0tNKhe5m9jPH7Om26x/AqKYbPo28H/NXPIExjvzv8X 7a3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YRN6qWsVu0mB1ku4fPTz09e+/lMrKAM1ocX41R6p7Gk=; fh=mNjlIp0QDNhBH9BdTTKLfvwAgYP+U/UGnZ56SlkFICk=; b=uqcSjz9WGISTejgASPffG9dn75DDBgu6Z377MkwysrFj4+ZBCDrWqNZCRaIlJn+cmN gGbXlGiWG6J0zLnaEWA+vs5dJ5zDtTn8rc/suYDtqVsdDJ5RCor2kJOtrhKGEqb5LGFb 3rQrzs+K8gZgs5SRnOyaF9vd5QTX5QuE1hniDU3HkHngaxZ69T8419g1X6TgKD6Zjm7h Nvs/IE2aLxTCr+mKgMElwTnw3+ld1dMc5apu9Iw/OzwIFlvOMNu3zU+8BAixibSM4O+z /QaAcjR9izwyp6H24xjMx6vt35D33HWtPS0jsivYYLVt9043DW5/JguS71sGs0vcRwXW nAqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=soWnwzrT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a63474c000000b005579a12f405si10502637pgk.200.2023.06.29.21.07.36; Thu, 29 Jun 2023 21:08:00 -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=@google.com header.s=20221208 header.b=soWnwzrT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229578AbjF3D1p (ORCPT + 99 others); Thu, 29 Jun 2023 23:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231501AbjF3D1n (ORCPT ); Thu, 29 Jun 2023 23:27:43 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D321135A5 for ; Thu, 29 Jun 2023 20:27:39 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-516500163b2so3244a12.1 for ; Thu, 29 Jun 2023 20:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688095658; x=1690687658; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YRN6qWsVu0mB1ku4fPTz09e+/lMrKAM1ocX41R6p7Gk=; b=soWnwzrTr9hKh0W3aqnqEN2ZcGCbufVtjT17NhzB4wsFdSXzlRDGZgj6fxlukK2MKn YsfdXQvKUaTg3JKW/BUM6tobUWXWciOdUv6jl2E9eGPg7EF9YV9WKQTP8f7DKOxvu/9v s0rl20ZxzAyL45Vn6SpokC6QcAWuBapLJ+lbzu0NiNjwXKd2V6pthnHll0r/Y//8sStD Q3AlCzR1YqBW3ivuGi7BdN4m+7yc8x0Lpugwqq1AcUmogleDxYyjpH+tgbsa3kYkEQUX 7vuSoyoAL717NLP88dWX6Xdmdf6/O+jP6oRM+a+ef9t+WWGF53lUE1yxazd3gLXJe2yo 25jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688095658; x=1690687658; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YRN6qWsVu0mB1ku4fPTz09e+/lMrKAM1ocX41R6p7Gk=; b=R3qwdzw1yIaaoYINlNh7SiXaBQeMZkAuHp5WKWzfK0euIpKyRDxPZIfOTzKdjagbh1 rh+hmph3l2mJLOdzobWTUUu1zS3DJsJwt+9CF+sPD3oeSTKODXuXlcT4/yhAHOxjC3UO XHQ/TEvQOsEKN73eHqh5Iw3mJKFKeCzBTTSjeUC6reuyamfvFX+Q+oNrl9/u8CHSzen+ I4726lxL7phFCSOZdhCtd9A90AbGGHEcmFP49XBbfVirS5ewgcsymjMYZh+iu2AS+4u+ mT812YXUrV2IKMPJVNNSLvgsSsFHPLWLb8ka+yQvrSeTPg4fb/vIhadAP4Q91cgJLaql yIbQ== X-Gm-Message-State: AC+VfDwo/rDC9sWynKBuBnQQJmnyJXBiY77Zi490Ku4RlkgJvlymyRFg NrQ+B0mT97hp8U0oGY701+5b6jrNZxUzqBsSKdfCJA== X-Received: by 2002:a50:baaf:0:b0:510:b2b7:8a78 with SMTP id x44-20020a50baaf000000b00510b2b78a78mr218316ede.5.1688095658215; Thu, 29 Jun 2023 20:27:38 -0700 (PDT) MIME-Version: 1.0 References: <20230629233454.4166842-1-jeffxu@google.com> In-Reply-To: <20230629233454.4166842-1-jeffxu@google.com> From: Jeff Xu Date: Thu, 29 Jun 2023 20:27:02 -0700 Message-ID: Subject: Re: [PATCH v2] Documentation: mm/memfd: vm.memfd_noexec To: jeffxu@chromium.org Cc: skhan@linuxfoundation.org, keescook@chromium.org, akpm@linux-foundation.org, dmitry.torokhov@gmail.com, dverkamp@chromium.org, hughd@google.com, jorgelo@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, jannh@google.com, linux-hardening@vger.kernel.org, linux-security-module@vger.kernel.org, Dominique Martinet Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Jun 29, 2023 at 4:34=E2=80=AFPM wrote: > > From: Jeff Xu > Please ignore this, I resent V3 with a cover letter. > Add documentation for sysctl vm.memfd_noexec > > Link:https://lore.kernel.org/linux-mm/CABi2SkXUX_QqTQ10Yx9bBUGpN1wByOi_= =3DgZU6WEy5a8MaQY3Jw@mail.gmail.com/T/ > Reported-by: Dominique Martinet > Signed-off-by: Jeff Xu > --- > Documentation/admin-guide/sysctl/vm.rst | 30 +++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admi= n-guide/sysctl/vm.rst > index 45ba1f4dc004..621588041a9e 100644 > --- a/Documentation/admin-guide/sysctl/vm.rst > +++ b/Documentation/admin-guide/sysctl/vm.rst > @@ -424,6 +424,36 @@ e.g., up to one or two maps per allocation. > > The default value is 65530. > > +memfd_noexec: > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > +This pid namespaced sysctl controls memfd_create(). > + > +The new MFD_NOEXEC_SEAL and MFD_EXEC flags of memfd_create() allows > +application to set executable bit at creation time. > + > +When MFD_NOEXEC_SEAL is set, memfd is created without executable bit > +(mode:0666), and sealed with F_SEAL_EXEC, so it can't be chmod to > +be executable (mode: 0777) after creation. > + > +when MFD_EXEC flag is set, memfd is created with executable bit > +(mode:0777), this is the same as the old behavior of memfd_create. > + > +The new pid namespaced sysctl vm.memfd_noexec has 3 values: > +0: memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL acts like > + MFD_EXEC was set. > +1: memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL acts like > + MFD_NOEXEC_SEAL was set. > +2: memfd_create() without MFD_NOEXEC_SEAL will be rejected. > + > +The default value is 0. > + > +Once set, it can't be downgraded at runtime, i.e. 2=3D>1, 1=3D>0 > +are denied. > + > +This is pid namespaced sysctl, child processes inherit the parent > +process's memfd_noexec at the time of fork. Changes to the parent > +process after fork are not automatically propagated to the child > +process. > > memory_failure_early_kill: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > -- > 2.41.0.255.g8b1d071c50-goog >