Commit badbbcd7 authored by Jeff Xu's avatar Jeff Xu Committed by Andrew Morton

selftests/memfd: sysctl: fix MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED

Add selftest for sysctl vm.memfd_noexec is 2
(MEMFD_NOEXEC_SCOPE_NOEXEC_ENFORCED)

memfd_create(.., MFD_EXEC) should fail in this case.

Link: https://lkml.kernel.org/r/20230705063315.3680666-3-jeffxu@google.comReported-by: default avatarDominique Martinet <asmadeus@codewreck.org>
Closes: https://lore.kernel.org/linux-mm/CABi2SkXUX_QqTQ10Yx9bBUGpN1wByOi_=gZU6WEy5a8MaQY3Jw@mail.gmail.com/T/Signed-off-by: default avatarJeff Xu <jeffxu@google.com>
Cc: Daniel Verkamp <dverkamp@chromium.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jorge Lucangeli Obes <jorgelo@chromium.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: kernel test robot <lkp@intel.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 72de2591
......@@ -1147,6 +1147,11 @@ static void test_sysctl_child(void)
sysctl_assert_write("2");
mfd_fail_new("kern_memfd_sysctl_2",
MFD_CLOEXEC | MFD_ALLOW_SEALING);
mfd_fail_new("kern_memfd_sysctl_2_MFD_EXEC",
MFD_CLOEXEC | MFD_EXEC);
fd = mfd_assert_new("", 0, MFD_NOEXEC_SEAL);
close(fd);
sysctl_fail_write("0");
sysctl_fail_write("1");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment