vmm: do not treat libc::MAP_FAILED as a pointer

It will likely be safely rejected by the kernel, but it's still wrong.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
Demi Marie Obenour
2025-06-21 20:18:37 -04:00
committed by Rob Bradford
parent 821f7994fc
commit 24998c1672

View File

@@ -2046,7 +2046,15 @@ impl MemoryManager {
file.as_raw_fd(),
0,
)
} as u64;
};
if host_addr == libc::MAP_FAILED {
error!(
"Could not add SGX EPC section (size 0x{:x})",
epc_section.size
);
return Err(Error::SgxEpcRangeAllocation);
}
info!(
"Adding SGX EPC section: 0x{:x} (0x{:x})",
@@ -2056,7 +2064,7 @@ impl MemoryManager {
let _mem_slot = self.create_userspace_mapping(
epc_section_start,
epc_section.size,
host_addr,
host_addr as u64,
false,
false,
false,