Use memfd secret
This commit is contained in:
@@ -3,7 +3,7 @@ use std::{
|
|||||||
usize,
|
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;
|
pub(crate) const MEMFD_INITIAL_SIZE: usize = 1024 * 1024;
|
||||||
const MMAP_SIZE: usize = 1024 * 1024;
|
const MMAP_SIZE: usize = 1024 * 1024;
|
||||||
@@ -26,7 +26,7 @@ impl BumpAllocator {
|
|||||||
unsafe fn new() -> Self {
|
unsafe fn new() -> Self {
|
||||||
assert!(MMAP_SIZE >= MEMFD_INITIAL_SIZE);
|
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);
|
assert!(data_fd > 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user