linux-stable/tools/testing
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
..
crypto/chacha20-s390
cxl tools/testing/cxl: Fix command effects for inject/clear poison 2023-07-19 16:36:23 +02:00
fault-injection
ktest ktest: Restore stty setting at first in dodie 2023-02-20 11:52:27 -05:00
kunit kunit: tool: undo type subscripts for subprocess.Popen 2023-07-19 16:35:17 +02:00
memblock mm, treewide: redefine MAX_ORDER sanely 2023-04-05 19:42:46 -07:00
nvdimm Driver core changes for 6.4-rc1 2023-04-27 11:53:57 -07:00
radix-tree XArray: Do not return sibling entries from xa_load() 2023-09-13 09:48:39 +02:00
scatterlist
selftests memfd: do not -EACCES old memfd_create() users with vm.memfd_noexec=2 2023-09-13 09:48:44 +02:00
vsock test/vsock: remove vsock_perf executable on `make clean` 2023-08-11 12:14:18 +02:00