[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f0bbf3a7920d86ff37edab5f0c085cb0afb5d8b9.1687344643.git.falcon@tinylab.org>
Date: Wed, 21 Jun 2023 21:17:25 +0800
From: Zhangjin Wu <falcon@...ylab.org>
To: w@....eu
Cc: thomas@...ch.de, arnd@...db.de, falcon@...ylab.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: [PATCH v1 15/17] selftests/nolibc: vfprintf: silence memfd_create() warning
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@...ylab.org>
---
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
Powered by blists - more mailing lists