Skip to content

Commit badbbcd

Browse files
Jeff Xuakpm00
authored andcommitted
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/[email protected] Reported-by: Dominique Martinet <[email protected]> Closes: https://lore.kernel.org/linux-mm/CABi2SkXUX_QqTQ10Yx9bBUGpN1wByOi_=gZU6WEy5a8MaQY3Jw@mail.gmail.com/T/ Signed-off-by: Jeff Xu <[email protected]> Cc: Daniel Verkamp <[email protected]> Cc: Dmitry Torokhov <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Jann Horn <[email protected]> Cc: Jorge Lucangeli Obes <[email protected]> Cc: Kees Cook <[email protected]> Cc: kernel test robot <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 72de259 commit badbbcd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/testing/selftests/memfd/memfd_test.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,11 @@ static void test_sysctl_child(void)
11471147
sysctl_assert_write("2");
11481148
mfd_fail_new("kern_memfd_sysctl_2",
11491149
MFD_CLOEXEC | MFD_ALLOW_SEALING);
1150+
mfd_fail_new("kern_memfd_sysctl_2_MFD_EXEC",
1151+
MFD_CLOEXEC | MFD_EXEC);
1152+
fd = mfd_assert_new("", 0, MFD_NOEXEC_SEAL);
1153+
close(fd);
1154+
11501155
sysctl_fail_write("0");
11511156
sysctl_fail_write("1");
11521157
}

0 commit comments

Comments
 (0)