mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-07 04:07:21 +00:00
memory_manager: use MFD_CLOEXEC flag when creating memory fd
Until there is a need for sharing the memory fd with a child process, we should err on the safe side to close it on exec. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
0cd6d96874
commit
b99b2bc990
@ -1252,9 +1252,8 @@ impl MemoryManager {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let fd = Self::memfd_create(
|
||||
&ffi::CString::new("ch_ram").unwrap(),
|
||||
if hugepages {
|
||||
let flags = libc::MFD_CLOEXEC
|
||||
| if hugepages {
|
||||
libc::MFD_HUGETLB
|
||||
| if let Some(hugepage_size) = hugepage_size {
|
||||
/*
|
||||
@ -1274,9 +1273,9 @@ impl MemoryManager {
|
||||
}
|
||||
} else {
|
||||
0
|
||||
},
|
||||
)
|
||||
.map_err(Error::SharedFileCreate)?;
|
||||
};
|
||||
let fd = Self::memfd_create(&ffi::CString::new("ch_ram").unwrap(), flags)
|
||||
.map_err(Error::SharedFileCreate)?;
|
||||
|
||||
let f = unsafe { File::from_raw_fd(fd) };
|
||||
f.set_len(size as u64).map_err(Error::SharedFileSetLen)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user