linux-stable/tools/testing/selftests
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
..
alsa selftests: alsa: pcm-test: Fix compiler warnings about the format 2023-06-05 09:15:42 +02:00
amd-pstate linux-kselftest-next-6.4-rc1 2023-04-24 12:28:34 -07:00
arm64 kselftest/arm64: Convert za-fork to use kselftest.h 2023-04-11 14:10:51 -06:00
bpf selftests/bpf: Clean up fmod_ret in bench_rename test script 2023-09-13 09:48:04 +02:00
breakpoints
capabilities
cgroup selftests: cgroup: fix unexpected failure on test_memcg_low 2023-07-19 16:35:27 +02:00
clone3 selftests/clone3: fix number of tests in ksft_set_plan 2023-04-06 11:57:28 +02:00
core selftests: core: Fix incorrect kernel headers search path 2023-01-30 15:04:52 -07:00
cpu-hotplug
cpufreq
damon selftests/damon/debugfs_rm_non_contexts: hide expected write error messages 2023-02-02 22:32:52 -08:00
dma
dmabuf-heaps selftests: dmabuf-heaps: Fix incorrect kernel headers search path 2023-02-13 09:09:44 -07:00
drivers selftests: bonding: do not set port down before adding to bond 2023-08-30 14:52:32 +02:00
efivarfs selftests/efivarfs: Add checking of the test return value 2022-11-22 09:09:04 -07:00
exec
filesystems linux-kselftest-next-6.3-rc1 2023-02-23 09:37:29 -08:00
firmware
fpu
ftrace selftests/ftace: Fix KTAP output ordering 2023-07-19 16:35:19 +02:00
futex selftests/futex: Order calls to futex_lock_pi 2023-09-13 09:47:58 +02:00
gpio selftests: gpio: gpio-sim: Fix BUG: test FAILED due to recent change 2023-05-11 14:41:45 +02:00
hid selftests: hid: import hid-tools usb-crash tests 2023-04-12 17:13:38 +02:00
ia64
intel_pstate
iommu iommufd/selftest: Cover domain unmap with huge pages and access 2023-04-04 13:11:24 -03:00
ipc selftests: ipc: Fix incorrect kernel headers search path 2023-02-13 09:09:44 -07:00
ir
kcmp selftests: kcmp: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
kexec
kmod testing: use the copyleft-next-0.3.1 SPDX tag 2022-11-08 15:44:02 +01:00
kselftest
kvm KVM: selftests: Add test for race in kvm_recalculate_apic_map() 2023-06-02 17:21:06 -07:00
landlock selftests/landlock: Test ptrace as much as possible with Yama 2023-01-27 18:53:55 +01:00
lib
livepatch
lkdtm
locking
media_tests selftests: media_tests: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
membarrier linux-kselftest-next-6.3-rc1 2023-02-23 09:37:29 -08:00
memfd memfd: do not -EACCES old memfd_create() users with vm.memfd_noexec=2 2023-09-13 09:48:44 +02:00
memory-hotplug
mincore
mm selftests/mm: FOLL_LONGTERM need to be updated to 0x100 2023-08-30 14:52:36 +02:00
mount
mount_setattr selftests mount: Fix mount_setattr_test builds failed 2023-03-31 09:18:45 -06:00
move_mount_set_group selftests: move_mount_set_group: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
mqueue
nci NFC: nci: Extend virtual NCI deinit test 2022-11-21 10:49:58 +00:00
net selftests: mirror_gre_changes: Tighten up the TTL test match 2023-08-23 17:32:44 +02:00
netfilter selftests: nft_flowtable.sh: check ingress/egress chain too 2023-05-10 09:31:07 +02:00
nolibc tools/nolibc: ensure fast64 integer types have 64 bits 2023-07-19 16:35:18 +02:00
nsfs
ntb
openat2
perf_events selftests: perf_events: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
pid_namespace selftests: pid_namespace: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
pidfd selftests: pidfd: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
powerpc selftests/powerpc/dscr: Restore timeout to DSCR selftests 2023-04-20 13:21:46 +10:00
prctl selftests: prctl: Add new prctl test for PR_SET_VMA action 2023-03-28 10:28:33 -06:00
proc selftests/proc: Assert clock_gettime(CLOCK_BOOTTIME) VS /proc/uptime monotonicity 2023-04-18 16:35:13 +02:00
pstore
ptp selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET 2023-06-15 15:07:23 -07:00
ptrace Update for entry and ptrace: 2023-04-25 11:05:04 -07:00
rcutorture rcutorture: Correct name of use_softirq module parameter 2023-07-19 16:35:17 +02:00
resctrl selftests/resctrl: Close perf value read fd on errors 2023-09-13 09:47:58 +02:00
riscv selftests: Test the new RISC-V hwprobe interface 2023-04-18 15:48:17 -07:00
rlimits
rseq selftests/rseq: Fix build with undefined __weak 2023-08-16 18:32:24 +02:00
rtc selftests: rtc: skip when RTC is not present 2022-11-15 13:30:51 -07:00
safesetid
sched selftests: sched: Add more core schedule prctl calls 2023-03-28 10:27:07 -06:00
seccomp LoongArch changes for v6.3 2023-03-01 09:27:00 -08:00
sgx selftests/sgx: Add "test_encl.elf" to TEST_FILES 2023-05-08 11:01:03 -06:00
sigaltstack selftests: sigaltstack: fix -Wuninitialized 2023-03-20 17:28:31 -06:00
size
sparc64
splice selftests: splice_read: Fix sysfs read cases 2022-11-29 17:28:31 -07:00
static_keys
sync selftests: sync: Fix incorrect kernel headers search path 2023-02-13 09:09:45 -07:00
syscall_user_dispatch
sysctl testing: use the copyleft-next-0.3.1 SPDX tag 2022-11-08 15:44:02 +01:00
tc-testing net/sched: taprio: Limit TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME to INT_MAX. 2023-08-11 12:14:14 +02:00
tdx selftests: tdx: Use installed kernel headers search path 2023-02-13 09:09:46 -07:00
timens
timers selftests/timers/posix_timers: Test delivery of signals across threads 2023-04-16 09:00:18 +02:00
tmpfs
tpm2 selftests: tpm2: remove redundant ord() 2023-02-13 09:09:46 -07:00
uevent
user
user_events selftests/user_events: Adapt dyn_test to non-persist events 2023-06-14 13:43:27 -04:00
vDSO kselftest: vDSO: Fix accumulation of uninitialized ret when CLOCK_REALTIME is undefined 2023-07-19 16:35:18 +02:00
watchdog
wireguard wireguard: netlink: send staged packets when setting initial private key 2023-07-19 16:37:02 +02:00
x86 Add support for new Linear Address Masking CPU feature. This is similar 2023-04-28 09:43:49 -07:00
zram
.gitignore
gen_kselftest_tar.sh
kselftest.h kselftest: Support nolibc 2023-04-11 14:10:47 -06:00
kselftest_deps.sh selftests/vm: rename selftests/vm to selftests/mm 2023-01-18 17:12:56 -08:00
kselftest_harness.h selftests/harness: Actually report SKIP for signal tests 2023-09-13 09:47:57 +02:00
kselftest_install.sh
kselftest_module.h
lib.mk selftests: fix LLVM build for i386 and x86_64 2023-03-10 13:41:10 -07:00
Makefile RISC-V Patches for the 6.4 Merge Window, Part 1 2023-04-28 16:55:39 -07:00
run_kselftest.sh