From 0200b3c91311f2f7bd5b5f74738ede773b584285 Mon Sep 17 00:00:00 2001 From: Aaron Kaiser Date: Tue, 14 May 2024 13:54:39 +0200 Subject: [PATCH] Use memfd secret --- src/bump_allocator.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bump_allocator.rs b/src/bump_allocator.rs index 6d99375..ed92f7d 100644 --- a/src/bump_allocator.rs +++ b/src/bump_allocator.rs @@ -3,7 +3,7 @@ use std::{ usize, }; -use libc::{c_char, c_void, ftruncate, memfd_create, mmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE}; +use libc::{c_void, ftruncate, mmap, syscall, SYS_memfd_secret, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE}; pub(crate) const MEMFD_INITIAL_SIZE: usize = 1024 * 1024; const MMAP_SIZE: usize = 1024 * 1024; @@ -26,7 +26,7 @@ impl BumpAllocator { unsafe fn new() -> Self { assert!(MMAP_SIZE >= MEMFD_INITIAL_SIZE); - let data_fd = memfd_create("data\x00".as_ptr() as *const c_char, 0); + let data_fd = syscall(SYS_memfd_secret, 0) as i32; assert!(data_fd > 0);