From 872df06b1d36488d40ac22b248e1b08c90bc02a3 Mon Sep 17 00:00:00 2001 From: myadav Date: Mon, 17 Feb 2025 22:04:40 -0500 Subject: [PATCH 1/3] change const to uppercase Signed-off-by: myadav --- src/hyperlight_guest/src/entrypoint.rs | 6 +++--- src/hyperlight_guest/src/lib.rs | 2 +- src/hyperlight_guest/src/security_check.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hyperlight_guest/src/entrypoint.rs b/src/hyperlight_guest/src/entrypoint.rs index f6fc15940..9006c2db6 100644 --- a/src/hyperlight_guest/src/entrypoint.rs +++ b/src/hyperlight_guest/src/entrypoint.rs @@ -27,8 +27,8 @@ use crate::guest_function_call::dispatch_function; use crate::guest_logger::init_logger; use crate::host_function_call::{outb, OutBAction}; use crate::{ - __security_cookie, HEAP_ALLOCATOR, MIN_STACK_ADDRESS, OS_PAGE_SIZE, OUTB_PTR, - OUTB_PTR_WITH_CONTEXT, P_PEB, RUNNING_MODE, + HEAP_ALLOCATOR, MIN_STACK_ADDRESS, OS_PAGE_SIZE, OUTB_PTR, OUTB_PTR_WITH_CONTEXT, P_PEB, + RUNNING_MODE, __SECURITY_COOKIE, }; #[inline(never)] @@ -84,7 +84,7 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_ unsafe { P_PEB = Some(peb_address as *mut HyperlightPEB); let peb_ptr = P_PEB.unwrap(); - __security_cookie = peb_address ^ seed; + __SECURITY_COOKIE = peb_address ^ seed; let srand_seed = ((peb_address << 8 ^ seed >> 4) >> 32) as u32; diff --git a/src/hyperlight_guest/src/lib.rs b/src/hyperlight_guest/src/lib.rs index ad8673acb..f5021672e 100644 --- a/src/hyperlight_guest/src/lib.rs +++ b/src/hyperlight_guest/src/lib.rs @@ -87,7 +87,7 @@ pub(crate) static HEAP_ALLOCATOR: LockedHeap<32> = LockedHeap::<32>::empty(); ///cbindgen:ignore #[no_mangle] -pub(crate) static mut __security_cookie: u64 = 0; +pub(crate) static mut __SECURITY_COOKIE: u64 = 0; pub(crate) static mut P_PEB: Option<*mut HyperlightPEB> = None; pub static mut MIN_STACK_ADDRESS: u64 = 0; diff --git a/src/hyperlight_guest/src/security_check.rs b/src/hyperlight_guest/src/security_check.rs index b21a94af8..44b7bd016 100644 --- a/src/hyperlight_guest/src/security_check.rs +++ b/src/hyperlight_guest/src/security_check.rs @@ -19,14 +19,14 @@ limitations under the License. use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode::GsCheckFailed; -use crate::__security_cookie; use crate::guest_error::set_error_and_halt; +use crate::__SECURITY_COOKIE; ///cbindgen:ignore #[no_mangle] pub(crate) extern "C" fn __security_check_cookie(cookie: u64) { unsafe { - if __security_cookie != cookie { + if __SECURITY_COOKIE != cookie { set_error_and_halt(GsCheckFailed, "GS Check Failed"); } } From 7ab3f3261c2830f0b4ba687f89f60899945d93b7 Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Mon, 17 Feb 2025 13:51:34 +0000 Subject: [PATCH 2/3] fix typos (#268) Signed-off-by: Simon Davies Signed-off-by: myadav --- src/hyperlight_host/benches/benchmarks.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hyperlight_host/benches/benchmarks.rs b/src/hyperlight_host/benches/benchmarks.rs index 6fcd6859c..db71d8a95 100644 --- a/src/hyperlight_host/benches/benchmarks.rs +++ b/src/hyperlight_host/benches/benchmarks.rs @@ -104,13 +104,13 @@ fn guest_call_benchmark(c: &mut Criterion) { fn sandbox_benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("sandboxes"); - // Benchmarks the time to create a new uninintialized sandbox. + // Benchmarks the time to create a new uninitialized sandbox. // Does **not** include the time to drop the sandbox. group.bench_function("create_uninitialized_sandbox", |b| { b.iter_with_large_drop(create_uninit_sandbox); }); - // Benchmarks the time to create a new uninintialized sandbox and drop it. + // Benchmarks the time to create a new uninitialized sandbox and drop it. group.bench_function("create_uninitialized_sandbox_and_drop", |b| { b.iter(create_uninit_sandbox); }); From acd9b2255c7d45e64fe49daa3305906f9b00fcd5 Mon Sep 17 00:00:00 2001 From: myadav Date: Tue, 18 Feb 2025 15:04:44 -0500 Subject: [PATCH 3/3] revert changes --- src/hyperlight_guest/src/entrypoint.rs | 6 +++--- src/hyperlight_guest/src/lib.rs | 2 +- src/hyperlight_guest/src/security_check.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hyperlight_guest/src/entrypoint.rs b/src/hyperlight_guest/src/entrypoint.rs index 9006c2db6..f6fc15940 100644 --- a/src/hyperlight_guest/src/entrypoint.rs +++ b/src/hyperlight_guest/src/entrypoint.rs @@ -27,8 +27,8 @@ use crate::guest_function_call::dispatch_function; use crate::guest_logger::init_logger; use crate::host_function_call::{outb, OutBAction}; use crate::{ - HEAP_ALLOCATOR, MIN_STACK_ADDRESS, OS_PAGE_SIZE, OUTB_PTR, OUTB_PTR_WITH_CONTEXT, P_PEB, - RUNNING_MODE, __SECURITY_COOKIE, + __security_cookie, HEAP_ALLOCATOR, MIN_STACK_ADDRESS, OS_PAGE_SIZE, OUTB_PTR, + OUTB_PTR_WITH_CONTEXT, P_PEB, RUNNING_MODE, }; #[inline(never)] @@ -84,7 +84,7 @@ pub extern "win64" fn entrypoint(peb_address: u64, seed: u64, ops: u64, max_log_ unsafe { P_PEB = Some(peb_address as *mut HyperlightPEB); let peb_ptr = P_PEB.unwrap(); - __SECURITY_COOKIE = peb_address ^ seed; + __security_cookie = peb_address ^ seed; let srand_seed = ((peb_address << 8 ^ seed >> 4) >> 32) as u32; diff --git a/src/hyperlight_guest/src/lib.rs b/src/hyperlight_guest/src/lib.rs index f5021672e..ad8673acb 100644 --- a/src/hyperlight_guest/src/lib.rs +++ b/src/hyperlight_guest/src/lib.rs @@ -87,7 +87,7 @@ pub(crate) static HEAP_ALLOCATOR: LockedHeap<32> = LockedHeap::<32>::empty(); ///cbindgen:ignore #[no_mangle] -pub(crate) static mut __SECURITY_COOKIE: u64 = 0; +pub(crate) static mut __security_cookie: u64 = 0; pub(crate) static mut P_PEB: Option<*mut HyperlightPEB> = None; pub static mut MIN_STACK_ADDRESS: u64 = 0; diff --git a/src/hyperlight_guest/src/security_check.rs b/src/hyperlight_guest/src/security_check.rs index 44b7bd016..b21a94af8 100644 --- a/src/hyperlight_guest/src/security_check.rs +++ b/src/hyperlight_guest/src/security_check.rs @@ -19,14 +19,14 @@ limitations under the License. use hyperlight_common::flatbuffer_wrappers::guest_error::ErrorCode::GsCheckFailed; +use crate::__security_cookie; use crate::guest_error::set_error_and_halt; -use crate::__SECURITY_COOKIE; ///cbindgen:ignore #[no_mangle] pub(crate) extern "C" fn __security_check_cookie(cookie: u64) { unsafe { - if __SECURITY_COOKIE != cookie { + if __security_cookie != cookie { set_error_and_halt(GsCheckFailed, "GS Check Failed"); } }