From 59b15541f39b794c8c27ed94dd9a413118e9d715 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 1 Oct 2024 23:15:54 +0800 Subject: [PATCH] add stubs for lifecycle management and update checking in loader this is just a reminder to me on how i was planning to implement this after going through a big side-quest to change other things. --- loader/src/main.rs | 3 +++ loader/src/platform/cramium/update.rs | 9 +++++++++ loader/src/platform/cramium/verifier.rs | 4 ++++ 3 files changed, 16 insertions(+) create mode 100644 loader/src/platform/cramium/update.rs create mode 100644 loader/src/platform/cramium/verifier.rs diff --git a/loader/src/main.rs b/loader/src/main.rs index 7265c8fcd..06b42b449 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -93,6 +93,9 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32) #[cfg(feature = "cramium-soc")] crate::platform::early_init(); // sets up PLLs so we're not running at 16MHz... + #[cfg(feature = "cramium-soc")] + crate::platform::process_update(); + // initially validate the whole image on disk (including kernel args) // kernel args must be validated because tampering with them can change critical assumptions about // how data is loaded into memory diff --git a/loader/src/platform/cramium/update.rs b/loader/src/platform/cramium/update.rs new file mode 100644 index 000000000..5aabce976 --- /dev/null +++ b/loader/src/platform/cramium/update.rs @@ -0,0 +1,9 @@ +/// Checks to see if the necessary conditions for an update are met +pub fn process_update() { + // Placeholder: + // Remember to lock the root keys before processing any updates + crate::platform::cramium::verifier::lifecycle_lock_root(); + { + // update code here + } +} diff --git a/loader/src/platform/cramium/verifier.rs b/loader/src/platform/cramium/verifier.rs new file mode 100644 index 000000000..f2cc70dff --- /dev/null +++ b/loader/src/platform/cramium/verifier.rs @@ -0,0 +1,4 @@ +pub fn lifecycle_lock_root() { + // placeholder to lock out access to root secrets due to the lifecycle being advanced past + // signature verification +}