From 9ea30b0cb23451572101184c2cb7e5fafa92e398 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 15 Apr 2024 17:44:47 +0100 Subject: [PATCH] Tested impl: works! Thoudh... XXX: man says `FD_CLOEXEC` should be passable to `memfd_secret()`, but it fails with `EINVAL` if passed `FD_CLOEXEC`...? Find out why? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for memfd_secret-shim's current commit: Blessing − 吉 --- src/memfd_secret.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memfd_secret.c b/src/memfd_secret.c index 16f1468..4119795 100644 --- a/src/memfd_secret.c +++ b/src/memfd_secret.c @@ -12,7 +12,7 @@ #define READ_ONCE(slot) ((__typeof__(slot))(*(const volatile __typeof__(slot)*)&(slot))) #define WRITE_ONCE(slot, value) (*((volatile __typeof__(slot)*)&(slot)) = (value)) -__attribute__((gnu_inline)) +__attribute__((gnu_inline/*, always_inline*/)) static inline int _memfd_secret_raw(unsigned int flags) { @@ -29,7 +29,7 @@ static inline int _has_memfd_secret_raw() { // Attempt syscall - int fd = _memfd_secret_raw(FD_CLOEXEC); + int fd = _memfd_secret(0); //XXX: NOTE: man page says `FD_CLOEXEC` is a valid flag, but using it returns `EINVAL`? // If failure to create new fd was caused by `ENOSYS`, it is not available. if(fd < 0 && errno == ENOSYS)