selftests: memfd/memfd_test.c: does not compile under AlmaLinux 8.7

Mirsad Todorovac posted 1 patch 2 years, 8 months ago
tools/testing/selftests/memfd/memfd_test.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
selftests: memfd/memfd_test.c: does not compile under AlmaLinux 8.7
Posted by Mirsad Todorovac 2 years, 8 months ago
Hi,

On AlmaLinux 8.7, make kselftest-all fails at memfd/memfd_test.c:

make[2]: Entering directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/memfd'
gcc -D_FILE_OFFSET_BITS=64 -isystem /home/marvin/linux/kernel/linux_torvalds/usr/include     memfd_test.c common.c  -o 
/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/memfd/memfd_test
memfd_test.c: In function ‘test_seal_future_write’:
memfd_test.c:916:27: error: ‘F_SEAL_FUTURE_WRITE’ undeclared (first use in this function); did you mean ‘F_SEAL_WRITE’?
   mfd_assert_add_seals(fd, F_SEAL_FUTURE_WRITE);
                            ^~~~~~~~~~~~~~~~~~~
                            F_SEAL_WRITE
memfd_test.c:916:27: note: each undeclared identifier is reported only once for each function it appears in
memfd_test.c: In function ‘test_exec_seal’:
memfd_test.c:36:7: error: ‘F_SEAL_FUTURE_WRITE’ undeclared (first use in this function); did you mean ‘F_SEAL_WRITE’?
        F_SEAL_FUTURE_WRITE | \
        ^~~~~~~~~~~~~~~~~~~
memfd_test.c:1058:27: note: in expansion of macro ‘F_WX_SEALS’
   mfd_assert_has_seals(fd, F_WX_SEALS);
                            ^~~~~~~~~~
make[2]: *** [../lib.mk:147: /home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/memfd/memfd_test] Error 1
make[2]: Leaving directory '/home/marvin/linux/kernel/linux_torvalds/tools/testing/selftests/memfd'

Apparently, the include file include/uapi/linux/fcntl.h defines this
F_SEAL_FUTURE_WRITE as 0x0010:

include/uapi/linux/fcntl.h:45:#define F_SEAL_FUTURE_WRITE	0x0010  /* prevent future writes while mapped */

This patch fixed the issue:

---
  tools/testing/selftests/memfd/memfd_test.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index dba0e8ba002f..868f17c02e32 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -28,7 +28,13 @@
  #define MFD_DEF_SIZE 8192
  #define STACK_SIZE 65536

-#define F_SEAL_EXEC    0x0020
+#ifndef F_SEAL_FUTURE_WRITE
+#define F_SEAL_FUTURE_WRITE    0x0010
+#endif
+
+#ifndef F_SEAL_EXEC
+#define F_SEAL_EXEC            0x0020
+#endif

  #define F_WX_SEALS (F_SEAL_SHRINK | \
                     F_SEAL_GROW | \


Hope this helps.

Best regards,
Mirsad

-- 
Mirsad Goran Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu

System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia