Skip to content

Commit

Permalink
Temporarily limit kernel command line length in Stage0 measurements
Browse files Browse the repository at this point in the history
As a temporary workaround for project-oak#4981, limit the kernel command line
included in the Stage0 DICE measurements to 256 chars (1024 bytes).
  • Loading branch information
kevinloughlin committed Apr 4, 2024
1 parent 8bdd773 commit b6a628e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions stage0/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use x86_64::{
};
use zerocopy::AsBytes;

use crate::{kernel::KernelType, sev::GHCB_WRAPPER, smp::AP_JUMP_TABLE};
use crate::{alloc::string::ToString, kernel::KernelType, sev::GHCB_WRAPPER, smp::AP_JUMP_TABLE};

mod acpi;
mod acpi_tables;
Expand Down Expand Up @@ -308,11 +308,17 @@ pub fn rust64_start(encrypted: u64) -> ! {
log::debug!("ACPI table generation digest: sha2-256:{}", hex::encode(acpi_sha2_256_digest));
log::debug!("E820 table digest: sha2-256:{}", hex::encode(memory_map_sha2_256_digest));

// TODO(#4981): Remove temporary workaround for command line length limit.
let cmdline_max_len = 256;
let measurements = oak_stage0_dice::Measurements {
acpi_sha2_256_digest,
kernel_sha2_256_digest: kernel_info.measurement,
cmdline_sha2_256_digest,
cmdline: cmdline.clone(),
cmdline: if cmdline.len() > cmdline_max_len {
cmdline[..cmdline_max_len].to_string()
} else {
cmdline.clone()
},
ram_disk_sha2_256_digest,
setup_data_sha2_256_digest,
memory_map_sha2_256_digest,
Expand Down

0 comments on commit b6a628e

Please sign in to comment.