vmm: memory_manager: Mark guest memory mappings as non-dumpable

Including the guest RAM (or other mapped memory) in a coredump is not
useful.

See: #5014

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2022-12-15 15:42:19 +00:00 committed by Sebastien Boeuf
parent 2b92a2778b
commit 795f2a5558

View File

@ -1580,6 +1580,20 @@ impl MemoryManager {
.create_user_memory_region(mem_region)
.map_err(Error::CreateUserMemoryRegion)?;
// SAFETY: the address and size are valid since the
// mmap succeeded.
let ret = unsafe {
libc::madvise(
userspace_addr as *mut libc::c_void,
memory_size as libc::size_t,
libc::MADV_DONTDUMP,
)
};
if ret != 0 {
let e = io::Error::last_os_error();
warn!("Failed to mark mappin as MADV_DONTDUMP: {}", e);
}
// Mark the pages as mergeable if explicitly asked for.
if mergeable {
// SAFETY: the address and size are valid since the