From 1b613510a91d00dda2d6cef005610d50696bd258 Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Mon, 17 Jun 2024 16:13:35 +0200 Subject: [PATCH] ASLR: Set self.aslr_status to True later We should probably tell Uhyve that it is enabled once we are sure that nothing has gone wrong. What we should do when something goes wrong (can anything go wrong?) is an open question. --- Cargo.toml | 2 +- src/vm.rs | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 824478de..60cbfac8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ path = "benches/benchmarks.rs" harness = false [features] -default = [] +default = ["aslr"] aslr = [] instrument = ["rftrace", "rftrace-frontend"] diff --git a/src/vm.rs b/src/vm.rs index c30360d2..b9e96205 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -194,17 +194,10 @@ impl UhyveVm { 0x3000000, ); - // TODO: Add test. (from end_address_upper_bound-0x000001 to end_address_upper_bound+0x000001) - // TODO: Is the mask alright? + // TODO: Add test. (from start_address_upper_bound-0x000001 to start_address_upper_bound+0x000001) // // We use 0x100000 as the offset for the start address so as to not use the zero page. - let kernel_random_address: u64 = - rng.gen_range(0x100000..start_address_upper_bound) & 0xffff_ffff_ffff_fff0; - - // TODO: Actually use this variable somewhere for something or completely remove it. - self.aslr_status = true; - - kernel_random_address + rng.gen_range(0x100000..start_address_upper_bound) & 0xffff_ffff_ffff_fff0 } pub fn load_kernel(&mut self) -> LoadKernelResult<()> { @@ -234,6 +227,10 @@ impl UhyveVm { kernel_start_address as u64, ); self.entry_point = entry_point; + #[cfg(feature = "aslr")] + { + self.aslr_status = true; + } let boot_info = BootInfo { hardware_info: HardwareInfo {