linux-stable/tools
Aleksa Sarai 6c7e870567 memfd: do not -EACCES old memfd_create() users with vm.memfd_noexec=2
[ Upstream commit 202e14222f ]

Given the difficulty of auditing all of userspace to figure out whether
every memfd_create() user has switched to passing MFD_EXEC and
MFD_NOEXEC_SEAL flags, it seems far less distruptive to make it possible
for older programs that don't make use of executable memfds to run under
vm.memfd_noexec=2.  Otherwise, a small dependency change can result in
spurious errors.  For programs that don't use executable memfds, passing
MFD_NOEXEC_SEAL is functionally a no-op and thus having the same

In addition, every failure under vm.memfd_noexec=2 needs to print to the
kernel log so that userspace can figure out where the error came from.
The concerns about pr_warn_ratelimited() spam that caused the switch to
pr_warn_once()[1,2] do not apply to the vm.memfd_noexec=2 case.

This is a user-visible API change, but as it allows programs to do
something that would be blocked before, and the sysctl itself was broken
and recently released, it seems unlikely this will cause any issues.

[1]: https://lore.kernel.org/Y5yS8wCnuYGLHMj4@x1n/
[2]: https://lore.kernel.org/202212161233.85C9783FB@keescook/

Link: https://lkml.kernel.org/r/20230814-memfd-vm-noexec-uapi-fixes-v2-2-7ff9e3e10ba6@cyphar.com
Fixes: 105ff5339f ("mm/memfd: add MFD_NOEXEC_SEAL and MFD_EXEC")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Daniel Verkamp <dverkamp@chromium.org>
Cc: Jeff Xu <jeffxu@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-13 09:48:44 +02:00
..
accounting delayacct: track delays from IRQ/SOFTIRQ 2023-04-18 16:39:34 -07:00
arch x86/bugs: Increase the x86 bugs vector size to two u32s 2023-08-08 20:04:51 +02:00
bootconfig bootconfig: Fix testcase to increase max node 2023-03-22 01:00:28 +09:00
bpf bpftool: Use a local bpf_perf_event_value to fix accessing its fields 2023-09-13 09:48:00 +02:00
build tools build: Add a feature test for scandirat(), that is not implemented so far in musl and uclibc 2023-04-04 13:18:17 -03:00
certs
cgroup
counter
debugging
edid
firewire
firmware
gpio tools: gpio: fix debounce_period_us output of lsgpio 2023-05-11 10:56:24 +02:00
hv vmbus_testing: fix wrong python syntax for integer value comparison 2023-09-13 09:47:53 +02:00
iio
include tools/nolibc: ensure stack protector guard is never zero 2023-07-27 08:56:48 +02:00
io_uring
kvm/kvm_stat tools/kvm_stat: use canonical ftrace path 2023-03-29 06:52:08 -04:00
laptop
leds
lib libbpf: Fix realloc API handling in zero-sized edge cases 2023-09-13 09:48:00 +02:00
memory-model LKMM scripting updates for v6.4 2023-04-24 12:02:25 -07:00
mm slab changes for 6.4 2023-04-25 13:00:41 -07:00
net/ynl tools: ynl-gen: fix enum index in _decode_enum(..) 2023-08-03 10:25:53 +02:00
objtool x86/retpoline,kprobes: Fix position of thunk sections with CONFIG_LTO_CLANG 2023-08-23 17:32:41 +02:00
pci
pcmcia
perf Revert "perf report: Append inlines to non-DWARF callchains" 2023-08-23 17:32:56 +02:00
power cpupower: Make TSC read per CPU for Mperf monitor 2023-05-08 10:46:49 -06:00
rcu
scripts sh updates for v6.4 2023-04-27 17:41:23 -07:00
spi
testing memfd: do not -EACCES old memfd_create() users with vm.memfd_noexec=2 2023-09-13 09:48:44 +02:00
thermal
time
tracing rtla/hwnoise: Reduce runtime to 75% 2023-07-19 16:36:36 +02:00
usb
verification rv: Fix addition on an uninitialized variable 'run' 2023-04-25 17:02:13 -04:00
virtio tools/virtio: fix build break for aarch64 2023-07-19 16:36:41 +02:00
wmi
Makefile tools/Makefile: do missed s/vm/mm/ 2023-04-18 14:22:12 -07:00