Skip to content

Commit

Permalink
microsoft.cloud-hypervisor: fix panic on ExtendedGuestReport
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Aug 22, 2024
1 parent ac330d8 commit 093955c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From e7980fa1acc9972073d394de86a48cee5410cd97 Mon Sep 17 00:00:00 2001
From: Tom Dohrmann <[email protected]>
Date: Wed, 14 Aug 2024 16:02:39 +0200
Subject: [PATCH] snp: fix panic when rejecting extended guest report

swei2_rw_gpa_arg.data is an array of size 16 and value.to_le_bytes() is
only 8 bytes.
---
hypervisor/src/mshv/mod.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs
index f60d8ceb..b8fccf31 100644
--- a/hypervisor/src/mshv/mod.rs
+++ b/hypervisor/src/mshv/mod.rs
@@ -962,7 +962,8 @@ impl cpu::Vcpu for MshvVcpu {
byte_count: std::mem::size_of::<u64>() as u32,
..Default::default()
};
- swei2_rw_gpa_arg.data.copy_from_slice(&value.to_le_bytes());
+ swei2_rw_gpa_arg.data[0..8]
+ .copy_from_slice(&value.to_le_bytes());
self.fd
.gpa_write(&mut swei2_rw_gpa_arg)
.map_err(|e| cpu::HypervisorCpuError::GpaWrite(e.into()))?;
--
2.45.1

6 changes: 4 additions & 2 deletions packages/by-name/microsoft/cloud-hypervisor/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

rustPlatform.buildRustPackage rec {
pname = "cloud-hypervisor";
version = "38.0.72.2";
version = "38.0.72";

src = fetchFromGitHub {
owner = "microsoft";
repo = "cloud-hypervisor";
rev = "refs/tags/msft/v${version}";
hash = "sha256-4Xpeu0MM59t5G0oFGLyG/CV5nRumzATArPRchxS8ONY=";
hash = "sha256-wGLRBMZUiGRphED0a+GvKPDyhZBtg6aYoyOlvRtmmEA=";
};

cargoLock = {
Expand All @@ -39,6 +39,8 @@ rustPlatform.buildRustPackage rec {
};
};

patches = [ ./0001-snp-fix-panic-when-rejecting-extended-guest-report.patch ];

separateDebugInfo = true;

nativeBuildInputs = [
Expand Down

0 comments on commit 093955c

Please sign in to comment.