Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21451885rwd; Thu, 29 Jun 2023 16:43:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xK2fevd2PX878FxET1TYYkBjQcvd0TwmdDAIEehIHMNgETkqUTj0C36KzGDDNuB2ngQWx X-Received: by 2002:a05:6a20:258e:b0:123:6bd8:90d5 with SMTP id k14-20020a056a20258e00b001236bd890d5mr1242794pzd.36.1688082233208; Thu, 29 Jun 2023 16:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688082233; cv=none; d=google.com; s=arc-20160816; b=asX2Z1TMGzcs/6Uy3Q/AS8PQbZurvqDR9ox5rTZ8RnIbGb1UR5THNJrYTgWH8V/Ga0 I8zsgDPOcOxP2gZx1buUQNKxtzNXDJEXJS+lVENc8pQbiH44zcL2psqyvjnXv7kWQmyQ uM7rWOltMkokdOSmSZVkVfEZtr1ihqXu+l/W/OORat/cPiCD54LYyy+m1NBv5uQdAa+2 IW/WsZ5kr97PWEL/xGVoclaYWhAuev7VboDfXE3SfVTmy72o7Mot2K5u1c7PXuGqX6H7 8GAC3rk/YGcTN8VzPMcw9M/nZtzmVcLonhMFa3KVl9DnJ3jCyKxXoiE05g9gJPJewvwm H3qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gG0p2NxJxfYPPHk57XaDb7PRgK5Ncrcc/zrK6bcWJBo=; fh=076cM3ixpW2bEOxq2EdNflNuCVm6DD+tbF6Bop7WsWM=; b=kwiwWbMFmffP+WwjsVdJXEmw1coPWSgC8nG12/ogw34hMy7iu6C227gZMFfiiYsm+Y HMOOQ9wczzxk4ILusnicV+BqtTCktbqZYei+h7/B1h5paozoZJ1DcPVdYJdDT+GUB6G6 rNqeXu9bLRF996c8tVbLjDE9Bag7JbLVmGO3jyj43IqcQO15gUu9CPAB+1GLeQVxcOGM eMFRyWlzHynQeRQBIqoBnEV+YzlM9qLwkTTk+VbFGlBqAhvvTHOPQqRzuxTtGjkOEV62 fctIrwO62ZYhVKl40MwsUExvsbfDqzRtMlss2AYBeFU8AlO43ktxw1NnHaizu67o3k7G 2QZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=V55WG+KN; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d3-20020a170903230300b001b85c935529si1527074plh.122.2023.06.29.16.43.38; Thu, 29 Jun 2023 16:43:53 -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=@chromium.org header.s=google header.b=V55WG+KN; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231804AbjF2XfK (ORCPT + 99 others); Thu, 29 Jun 2023 19:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231831AbjF2XfB (ORCPT ); Thu, 29 Jun 2023 19:35:01 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EACB170B for ; Thu, 29 Jun 2023 16:34:59 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1b09276ed49so1146077fac.1 for ; Thu, 29 Jun 2023 16:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1688081699; x=1690673699; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gG0p2NxJxfYPPHk57XaDb7PRgK5Ncrcc/zrK6bcWJBo=; b=V55WG+KNmomp8p6ckLhRrH+LXm07woxdK5aExRC5Ap8XBsUXarBgSTLvYxJcJOWLaH SZ94W8McRnwkd8EJtqtJiuP1Mqbaua+C+BgrqDU+dRC3HJ6HjxS4ALWXnq5izdYa0aWa TIiVjfq4PS1K8Y+0KXOb27kFxC49e6PrVjVQU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688081699; x=1690673699; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gG0p2NxJxfYPPHk57XaDb7PRgK5Ncrcc/zrK6bcWJBo=; b=SlbE3Js6jIFIN/IauA+pufOW4M0h6PLADkxinRw5yvgN9z7ayeH1IGCH6cClaJOFA7 IgftePmWfpqfT19iu3dWc9RZPWJS5XQMNZ4YtjpMSTQXKADJfKXWtPNpeUFkTeHJrq+6 kQN8dZR4xuEvNYaIGzQv/398LFONr8JbpF8Hldo542JM6ASklqbnAutBlu9I1UjAPIpe NV9Gd2daBYZNoXMO3jHAF0vJTH1mIa85//XlLgpQjAlVInh7qsrAMkVYD4fcY2Cq0IOe Ex/L6iLBZ+feqgnK5No/KOTJCJIl78rrXOe4lzMAQOJUVNiA0QCFN/8NO65kq4h1gsBa VoRg== X-Gm-Message-State: AC+VfDwlI2J6eo3mCy20ow8RE0cDAzJ7NlW+O2+/36QHOZlFlsLVkfQL qKsy/sYhBGv5gG0vRGI2+BbRGg== X-Received: by 2002:a05:6870:7c13:b0:1b0:432d:acb7 with SMTP id je19-20020a0568707c1300b001b0432dacb7mr1706353oab.35.1688081698833; Thu, 29 Jun 2023 16:34:58 -0700 (PDT) Received: from localhost (183.43.230.35.bc.googleusercontent.com. [35.230.43.183]) by smtp.gmail.com with UTF8SMTPSA id n59-20020a17090a2cc100b0025bdc3454c6sm12441785pjd.8.2023.06.29.16.34.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jun 2023 16:34:58 -0700 (PDT) From: jeffxu@chromium.org To: skhan@linuxfoundation.org, keescook@chromium.org Cc: akpm@linux-foundation.org, dmitry.torokhov@gmail.com, dverkamp@chromium.org, hughd@google.com, jeffxu@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 Subject: [PATCH v2] Documentation: mm/memfd: vm.memfd_noexec Date: Thu, 29 Jun 2023 23:34:54 +0000 Message-ID: <20230629233454.4166842-1-jeffxu@google.com> X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Jeff Xu Add documentation for sysctl vm.memfd_noexec Link:https://lore.kernel.org/linux-mm/CABi2SkXUX_QqTQ10Yx9bBUGpN1wByOi_=gZU6WEy5a8MaQY3Jw@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/admin-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: +============= +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=>1, 1=>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: ========================== -- 2.41.0.255.g8b1d071c50-goog