lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250715050629.1513826-3-alviro.iskandar@gnuweeb.org>
Date: Tue, 15 Jul 2025 12:06:28 +0700
From: Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	io-uring Mailing List <io-uring@...r.kernel.org>,
	GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
	Ammar Faizi <ammarfaizi2@...weeb.org>
Subject: [PATCH liburing 2/3] test: Move `memfd_create()` to helpers.c, make it accessible for all tests

Previously, the static definition of `memfd_create()` was limited to
io_uring_register.c. Now, promote it to a shared location accessible
to all test cases, ensuring that future tests using `memfd_create()`
do not trigger build failures on Android targets where the syscall
is undefined in the standard headers. It improves portability and
prevents regressions across test builds.

Co-authored-by: Ammar Faizi <ammarfaizi2@...weeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@...weeb.org>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>
---
 test/helpers.c           |  8 ++++++++
 test/helpers.h           |  5 +++++
 test/io_uring_register.c | 11 -----------
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/test/helpers.c b/test/helpers.c
index 0589548..f1d4477 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -18,6 +18,14 @@
 #include "helpers.h"
 #include "liburing.h"
 
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <sys/syscall.h>
+int memfd_create(const char *name, unsigned int flags)
+{
+	return (int)syscall(SYS_memfd_create, name, flags);
+}
+#endif
+
 /*
  * Helper for allocating memory in tests.
  */
diff --git a/test/helpers.h b/test/helpers.h
index 3f0c11a..8ab0920 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -122,6 +122,11 @@ unsigned long long mtime_since_now(struct timeval *tv);
 unsigned long long utime_since(const struct timeval *s, const struct timeval *e);
 unsigned long long utime_since_now(struct timeval *tv);
 
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#endif
+int memfd_create(const char *name, unsigned int flags);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/test/io_uring_register.c b/test/io_uring_register.c
index f08f0ca..c36c4d8 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -32,17 +32,6 @@ static int pagesize;
 static rlim_t mlock_limit;
 static int devnull;
 
-#if !defined(CONFIG_HAVE_MEMFD_CREATE)
-#include <sys/syscall.h>
-#include <linux/memfd.h>
-
-static int memfd_create(const char *name, unsigned int flags)
-{
-	return (int)syscall(SYS_memfd_create, name, flags);
-}
-#endif
-
-
 static int expect_fail(int fd, unsigned int opcode, void *arg,
 		       unsigned int nr_args, int error, int error2)
 {
-- 
Alviro Iskandar Setiawan


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ