Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1286576lqt; Fri, 7 Jun 2024 13:36:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0Hrx9Mp2F9tPqTSZzIjUVI54xXC0h/VxvO2m0/1pQeB5azOxLuYfBEML+BkD7BdcZvaP9s0gTTA/3bfDI5HQ0VbEbR6HX/C8nKnV+bA== X-Google-Smtp-Source: AGHT+IEBz6vBuINK3jvx1p0mC5V4W0NJaSYYdTlzZ0sr1Ca4dDq3RwOkBXEfAJttIbaTvcD3d2Pc X-Received: by 2002:a05:620a:382:b0:795:19fc:54a with SMTP id af79cd13be357-7953c32053cmr314106085a.17.1717792564181; Fri, 07 Jun 2024 13:36:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717792564; cv=pass; d=google.com; s=arc-20160816; b=bu1X0CUQYGzFGkp5A069dvaIwS3nIpy7DxhSVrHd8Ud99hXRj5b+dc+1wPtMEcLglI BG3UEmdk46xGyq3zUFkYMoo4K5vGPdHvXAgxVBOr5LOPRfS3Icb3pkQ0pcOlt2RFJOId DUpGDbvuUwf8LyUMb6+hWuEepnamLKeGDWRwZtBqtoWyfFTRGukPY+aq2tx9lV812cIt s0GrpSfzC9q7TP6A8yPCPCH00Vn/Yown2jW3rRY9/FqVjWSnJtZNR6eHwG6OiYW5LeY3 VdfCt8VoTzbmUv0D5MO/58OU0kp6l/20/Sw/DaxOi75lEeHSP0Bap+YJhfbjJ4hBWUT0 gvpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=/aZumHyRcpOIT74DOJSEusSl9YmG7Mt7kBbt+rZmDfc=; fh=B7JJxkS6Ubz/AB4LdSvZFe2ckRTvfmaw487mdX3qLTo=; b=f4gUU6o/wGcDvTU3ZvkSEBvSltP6k4LcZoDAxAxXHPad/IIsecGkfZ6qs7V+ZO0bdb gt5dX3Y0/WMd5aZItQmFzm0qMDO17ZRTiFWt7BDw+2qC9/uSSdnblN9nI/VIIrECJvnU 4XBKglaUgxqdjDi6333f0G621Ri4fSGBQFe7l+OVyYOGnYaeKprO00+nN+tEMSI8pdel 7wuz4ekluJ2IQ9uBj8iS5RZPUK8AOgzBHZ/DrTwuz0Bl0OUZKb4vp9E5hxZkfYbOAt9t eT4HjqYuGe++ke04N8v4zARaxrKoGVhFKey01prGd9X3zXRhkYuih5csDKjx1P0FL4ZC heeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yu8c9Syv; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-206727-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206727-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-79532894737si470025685a.210.2024.06.07.13.36.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 13:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206727-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yu8c9Syv; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-206727-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206727-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DEE121C21A6B for ; Fri, 7 Jun 2024 20:36:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51C19153508; Fri, 7 Jun 2024 20:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Yu8c9Syv" Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC006819 for ; Fri, 7 Jun 2024 20:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792556; cv=none; b=E6lR1uyREha/G6b6EVsHddaWh9aURHAKUfi3+82poji9t88yDIx4KEHckaxWsZ32slRyTggjOWyL3aVl4BaPEv0vYX69m0EkmfKN2PXTn7EPIBiUCWO3WRSCG0RGrVxPyNaYiLYuU6dsB/LTeThrC4BHHayKmfZioXu0BSl8okE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792556; c=relaxed/simple; bh=0oUY7YekuzTgZuoCTclJAAQEBpsdR68wucgu8oAuMyg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=tMKkdZatJPe/vg6orecDwyD8q+ntz1AwcJk/jbUMF/dgDYOLe2L3Eu06l7Hze1DJdUvjeCMgt8SMbYoIFY+zvrdCAQ8WBbZ2y915QLmxBuXUQSKgw0dbjo3zdqr+yzKkB+ZUVmROXj8WoSFxYrcvLiUi8getI0UmF21fGikXNwk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Yu8c9Syv; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-6e57506bb2dso456530a12.0 for ; Fri, 07 Jun 2024 13:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1717792553; x=1718397353; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/aZumHyRcpOIT74DOJSEusSl9YmG7Mt7kBbt+rZmDfc=; b=Yu8c9SyvgOlVfndEI1c3sF7rl+2xLUBM5r4MAKSuEpDyrc4OJaURtDXOFAjzh3w83d K1lX4xG+6jC2W9XbzQpn1y0c++GYLmYIJ07eZWkmMkCocpNFvmB8TUfTWXsEEyfGi6iB vfmNZ3qlNpJ9QKkuhSsO6O2ZRS1qHyLojlUmU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717792553; x=1718397353; 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=/aZumHyRcpOIT74DOJSEusSl9YmG7Mt7kBbt+rZmDfc=; b=BrPHqOpxlLrhzZlBYIGqIUdd7ILKrzLUZRvf6sabKb8cEqC5ghoritlD+4iCg/1N/8 u3Txqo200uVXhhyrUI7Y9tOAQcGfS0d5vicQOhWQKmZ+N5aTmr4ZU3zfOpf7gbJBbf4Q VZuuFdUoUkRShpOW6gSGUD+g08UWYQ9ELIcEEENPn6EAfDvzlh1qxEDnnZEtvtJYmTAY joFTJVv0u2O22KlZ4g9ntQ25unumpp/6G92KzrVB+lbEKZCBPbgIe5GWzPj+VqrR/v1r JyyI/qoyxUQ99M+wKqmybkxlQcgKSFtBbDz/AIUXtqnHRsqxlT/pkXP3AUEfNDmwYC1/ SQvA== X-Forwarded-Encrypted: i=1; AJvYcCXMOtWCMq2vdTC5OLK1hSkYOmxF+tcByP3VL2VXJg4gtdYqHDKPyml+AUfhmhCRjKTb/RPffLsiA8IwiJ3Nuet3F2c7Bn/Y0ylI3z8u X-Gm-Message-State: AOJu0Yy87wYdkoQ4wgVLTtwwwZyRFrkv6iNq0b55QAhGyASBIyPeDq71 Xc30DGKAPF6DSIvUMRxM8S36uLma4aumVltS2VMhf6d0MiEZn34YlJMSoWjK0Q== X-Received: by 2002:a17:90a:ee4a:b0:2c1:aa8e:d70 with SMTP id 98e67ed59e1d1-2c2bc7cf895mr4084944a91.0.1717792553031; Fri, 07 Jun 2024 13:35:53 -0700 (PDT) Received: from localhost (213.126.145.34.bc.googleusercontent.com. [34.145.126.213]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2c2806d1be2sm5904787a91.55.2024.06.07.13.35.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jun 2024 13:35:52 -0700 (PDT) From: jeffxu@chromium.org To: jeffxu@chromium.org Cc: akpm@linux-foundation.org, cyphar@cyphar.com, david@readahead.eu, dmitry.torokhov@gmail.com, dverkamp@chromium.org, hughd@google.com, jeffxu@google.com, jorgelo@chromium.org, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, pobrn@protonmail.com, skhan@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH v1 0/1] mm/memfd: add documentation for MFD_NOEXEC_SEAL Date: Fri, 7 Jun 2024 20:35:40 +0000 Message-ID: <20240607203543.2151433-1-jeffxu@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jeff Xu When MFD_NOEXEC_SEAL was introduced, there was one big mistake: it didn't have proper documentation. This led to a lot of confusion, especially about whether or not memfd created with the MFD_NOEXEC_SEAL flag is sealable. Before MFD_NOEXEC_SEAL, memfd had to explicitly set MFD_ALLOW_SEALING to be sealable, so it's a fair question. As one might have noticed, unlike other flags in memfd_create, MFD_NOEXEC_SEAL is actually a combination of multiple flags. The idea is to make it easier to use memfd in the most common way, which is NOEXEC + F_SEAL_EXEC + MFD_ALLOW_SEALING. This works with sysctl vm.noexec to help existing applications move to a more secure way of using memfd. Proposals have been made to put MFD_NOEXEC_SEAL non-sealable, unless MFD_ALLOW_SEALING is set, to be consistent with other flags [1] [2], Those are based on the viewpoint that each flag is an atomic unit, which is a reasonable assumption. However, MFD_NOEXEC_SEAL was designed with the intent of promoting the most secure method of using memfd, therefore a combination of multiple functionalities into one bit. Furthermore, the MFD_NOEXEC_SEAL has been added for more than one year, and multiple applications and distributions have backported and utilized it. Altering ABI now presents a degree of risk and may lead to disruption. MFD_NOEXEC_SEAL is a new flag, and applications must change their code to use it. There is no backward compatibility problem. When sysctl vm.noexec == 1 or 2, applications that don't set MFD_NOEXEC_SEAL or MFD_EXEC will get MFD_NOEXEC_SEAL memfd. And old-application might break, that is by-design, in such a system vm.noexec = 0 shall be used. Also no backward compatibility problem. I propose to include this documentation patch to assist in clarifying the semantics of MFD_NOEXEC_SEAL, thereby preventing any potential future confusion. This patch supersede previous patch which is trying different direction [3], and please remove [2] from mm-unstable branch when applying this patch. Finally, I would like to express my gratitude to David Rheinsberg and Barnabás Pőcze for initiating the discussion on the topic of sealability. [1] https://lore.kernel.org/lkml/20230714114753.170814-1-david@readahead.eu/ [2] https://lore.kernel.org/lkml/20240513191544.94754-1-pobrn@protonmail.com/ [3] https://lore.kernel.org/lkml/20240524033933.135049-1-jeffxu@google.com/ Jeff Xu (1): mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/mfd_noexec.rst | 86 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Documentation/userspace-api/mfd_noexec.rst -- 2.45.2.505.gda0bf45e8d-goog