Skip to content

Commit

Permalink
ASLR: Set self.aslr_status to True later
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
n0toose committed Jun 17, 2024
1 parent 6eb3a18 commit 1b61351
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ path = "benches/benchmarks.rs"
harness = false

[features]
default = []
default = ["aslr"]
aslr = []
instrument = ["rftrace", "rftrace-frontend"]

Expand Down
15 changes: 6 additions & 9 deletions src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,10 @@ impl<VCpuType: VirtualCPU> UhyveVm<VCpuType> {
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<()> {
Expand Down Expand Up @@ -234,6 +227,10 @@ impl<VCpuType: VirtualCPU> UhyveVm<VCpuType> {
kernel_start_address as u64,
);
self.entry_point = entry_point;
#[cfg(feature = "aslr")]
{
self.aslr_status = true;
}

let boot_info = BootInfo {
hardware_info: HardwareInfo {
Expand Down

0 comments on commit 1b61351

Please sign in to comment.