Skip to content

Commit

Permalink
Ignore MFD_EXEC.
Browse files Browse the repository at this point in the history
  • Loading branch information
shkhln committed May 25, 2024
1 parent 0545d82 commit 72babd7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/libc/sys/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#define LINUX_MEMFD_CREATE 319
#endif

#define LINUX_MFD_CLOEXEC 0x01
#define LINUX_MFD_ALLOW_SEALING 0x02
#define LINUX_MFD_EXEC 0x10

void* shim_mmap_impl(void*, size_t, int, int, int, linux_off_t);
int shim_open_impl(const char*, int, va_list);

Expand Down Expand Up @@ -198,12 +202,16 @@ long shim_syscall_impl(long number, va_list args) {

if (number == LINUX_MEMFD_CREATE) {
#if __FreeBSD_version >= 1300139
char* name = va_arg(args, char*);
int flags = va_arg(args, int);
char* name = va_arg(args, char*);
int linux_flags = va_arg(args, int);

LOG("%s: memfd_create(\"%s\", 0x%x)", __func__, name, linux_flags);

LOG("%s: memfd_create(\"%s\", 0x%x)", __func__, name, flags);
assert((linux_flags & ~(LINUX_MFD_CLOEXEC | LINUX_MFD_ALLOW_SEALING | LINUX_MFD_EXEC)) == 0);

assert((flags & (MFD_CLOEXEC | MFD_ALLOW_SEALING)) == flags);
int flags = 0;
if (linux_flags & LINUX_MFD_CLOEXEC) flags |= MFD_CLOEXEC;
if (linux_flags & LINUX_MFD_ALLOW_SEALING) flags |= MFD_ALLOW_SEALING;

int err = memfd_create(name, flags);

Expand Down

0 comments on commit 72babd7

Please sign in to comment.