pass MFD_NOEXEC_SEAL flag to memfd_create() to silence this kernel warning inserted in the middle of the whole test result: memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 The mixed test result looks this: Running test 'vfprintf' 0 emptymemfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 'init' "" = "" [OK] >From v6.2, MFD_NOEXEC_SEAL must be passed for the non-executable memfd. Since MFD_NOEXEC_SEAL is a whole new flag, to avoid adding ugly #ifdef macros, let's use magic number here directly. Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx> --- tools/testing/selftests/nolibc/nolibc-test.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 19e4ef5ce578..8b1ce9911c5c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -774,7 +774,17 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char FILE *memfile; va_list args; - fd = memfd_create("vfprintf", 0); + /* silence warning for kernel >= v6.2: + * + * "memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=<pid>" + * + * try MFD_NOEXEC_SEAL (0x0008U) flag for kernels >= v6.2, error means + * the kernel is too old and require old flags + */ + fd = memfd_create("vfprintf", 0x0008U); + if (fd == -1) + fd = memfd_create("vfprintf", 0); + if (fd == -1) { pad_spc(llen, 64, "[FAIL]\n"); return 1; -- 2.25.1