From 616c7d4398fcd14bb738f73d6c56f65ada622c46 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 10 Mar 2024 19:37:26 +0100 Subject: [PATCH] Load the bootstrap blob at 4096 instead of 0 This way the NULL page can stay unmapped and the bootstrap code can avoid UB when reading the initfs header (which is at the start of the bootstrap code. --- src/syscall/process.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syscall/process.rs b/src/syscall/process.rs index 8b3df1c8c9..0d6d2bf56b 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -581,7 +581,7 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap) -> ! { .expect("expected bootstrap context to have an address space"), ); - let base = Page::containing_address(VirtualAddress::new(0)); + let base = Page::containing_address(VirtualAddress::new(4096)); let flags = MapFlags::MAP_FIXED_NOREPLACE | MapFlags::PROT_EXEC | MapFlags::PROT_READ | MapFlags::PROT_WRITE; let page_count = NonZeroUsize::new(bootstrap.page_count) @@ -594,7 +594,7 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap) -> ! { } // TODO: Not all arches do linear mapping - UserSliceWo::new(0, bootstrap.page_count * PAGE_SIZE) + UserSliceWo::new(4096, bootstrap.page_count * PAGE_SIZE) .expect("failed to create bootstrap user slice") .copy_from_slice(unsafe { bootstrap_mem(bootstrap) }) .expect("failed to copy memory to bootstrap");