linux-stable/Documentation
Jeff Xu 653c5c7511 mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
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], 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.

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/

[jeffxu@chromium.org: updates per Randy]
  Link: https://lkml.kernel.org/r/20240611034903.3456796-2-jeffxu@chromium.org
[jeffxu@chromium.org: v3]
  Link: https://lkml.kernel.org/r/20240611231409.3899809-2-jeffxu@chromium.org
Link: https://lkml.kernel.org/r/20240607203543.2151433-2-jeffxu@google.com
Signed-off-by: Jeff Xu <jeffxu@chromium.org>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Aleksa Sarai <cyphar@cyphar.com>
Cc: Barnabás Pőcze <pobrn@protonmail.com>
Cc: Daniel Verkamp <dverkamp@chromium.org>
Cc: David Rheinsberg <david@readahead.eu>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jorge Lucangeli Obes <jorgelo@chromium.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-06-15 10:43:07 -07:00
..
ABI Char/Misc and other driver subsystem changes for 6.10-rc1 2024-05-22 12:26:46 -07:00
accel
accounting
admin-guide Revert "mm: init_mlocked_on_free_v3" 2024-06-15 10:43:05 -07:00
arch Documentation: RISC-V: uabi: Only scalar misaligned loads are supported 2024-05-30 09:42:53 -07:00
block
bpf bpf, docs: Fix the description of 'src' in ALU instructions 2024-05-15 09:34:54 -07:00
cdrom scsi: sr: Fix unintentional arithmetic wraparound 2024-05-15 10:05:24 -04:00
core-api Documentation/core-api: correct reference to SWIOTLB_DYNAMIC 2024-05-27 16:52:09 +02:00
cpu-freq
crypto
dev-tools Mainly singleton patches, documented in their respective changelogs. 2024-05-19 14:02:03 -07:00
devicetree for-linus-2024060801 2024-06-08 10:48:11 -07:00
doc-guide
driver-api Char/Misc and other driver subsystem changes for 6.10-rc1 2024-05-22 12:26:46 -07:00
fault-injection
fb
features
filesystems 16 hotfixes, 11 of which are cc:stable. 2024-05-25 15:10:33 -07:00
firmware-guide
firmware_class
fpga
gpu
hid Merge branch 'for-6.10/intel-ish' into for-linus 2024-05-14 13:53:15 +02:00
hwmon hwmon: (emc1403) Add support for EMC1428 and EMC1438. 2024-05-12 09:02:00 -07:00
i2c
iio
images
infiniband
input
isdn
kbuild kconfig: doc: document behavior of 'select' and 'imply' followed by 'if' 2024-06-06 20:05:15 +09:00
kernel-hacking
leds
litmus-tests Documentation/litmus-tests: Make cmpxchg() tests safe for klitmus 2024-05-06 14:29:21 -07:00
livepatch
locking
maintainer
mhi
misc-devices
mm The usual shower of singleton fixes and minor series all over MM, 2024-05-19 09:21:03 -07:00
netlabel
netlink netdev: add qstat for csum complete 2024-05-30 12:15:56 +02:00
networking Revert "xsk: Document ability to redirect to any socket bound to the same umem" 2024-06-05 09:43:05 +02:00
nvdimm
nvme
PCI Merge branch 'pci/enumeration' 2024-05-16 18:14:10 -05:00
pcmcia
peci
power
process docs: netdev: Fix typo in Signed-off-by tag 2024-05-27 17:15:22 -07:00
RCU
rust RISC-V Patches for the 6.10 Merge Window, Part 1 2024-05-22 09:56:00 -07:00
scheduler
scsi
security Another not-too-busy cycle for documentation, including: 2024-05-13 10:51:53 -07:00
sound Documentation: sound: Fix trailing whitespaces 2024-05-16 16:00:30 +02:00
sphinx docs: kernel_include.py: Cope with docutils 0.21 2024-05-02 09:50:59 -06:00
sphinx-static
spi spi: pxa2xx: Drop the stale entry in documentation TOC 2024-05-07 23:53:21 +09:00
staging
target
tee
timers
tools rtla: Documentation: Fix -t, --trace 2024-05-16 16:52:16 +02:00
trace Char/Misc and other driver subsystem changes for 6.10-rc1 2024-05-22 12:26:46 -07:00
translations pci-v6.10-changes 2024-05-21 10:09:28 -07:00
usb
userspace-api mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC 2024-06-15 10:43:07 -07:00
virt powerpc updates for 6.10 2024-05-17 09:05:46 -07:00
w1
watchdog
wmi
.gitignore
atomic_bitops.txt
atomic_t.txt Documentation/atomic_t: Emphasize that failed atomic operations give no ordering 2024-05-06 14:29:04 -07:00
Changes
CodingStyle
conf.py
docutils.conf
dontdiff
index.rst
Kconfig
Makefile Kbuild updates for v6.10 2024-05-18 12:39:20 -07:00
memory-barriers.txt
SubmittingPatches
subsystem-apis.rst