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-4-alviro.iskandar@gnuweeb.org>
Date: Tue, 15 Jul 2025 12:06:29 +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 3/3] examples: Add `memfd_create()` helper

Add `memfd_create()` helper to handle missing defintion on an environment
where `CONFIG_HAVE_MEMFD_CREATE` is not defined.

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>
---
 examples/helpers.c | 8 ++++++++
 examples/helpers.h | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/examples/helpers.c b/examples/helpers.c
index 483ddee..8c112f1 100644
--- a/examples/helpers.c
+++ b/examples/helpers.c
@@ -13,6 +13,14 @@
 
 #include "helpers.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
+
 int setup_listening_socket(int port, int ipv6)
 {
 	struct sockaddr_in srv_addr = { };
diff --git a/examples/helpers.h b/examples/helpers.h
index 44543e1..0b6f15f 100644
--- a/examples/helpers.h
+++ b/examples/helpers.h
@@ -17,4 +17,9 @@ void *t_aligned_alloc(size_t alignment, size_t size);
 
 void t_error(int status, int errnum, const char *format, ...);
 
+#ifndef CONFIG_HAVE_MEMFD_CREATE
+#include <linux/memfd.h>
+#endif
+int memfd_create(const char *name, unsigned int flags);
+
 #endif
-- 
Alviro Iskandar Setiawan


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ