Skip to content

Commit 959ede0

Browse files
authored
Merge pull request coconut-svsm#1074 from stefano-garzarella/fix-tpm-allocation
kernel/vtpm: fix uninitialized heap bytes returned in TPM failure mode
2 parents 7e4caaa + ca7a9a5 commit 959ede0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kernel/src/vtpm/tcgtpm/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ impl TcgTpmSimulatorInterface for TcgTpm {
120120
if response_ffi_size == 0 || response_ffi_size as usize > response_ffi.capacity() {
121121
return Err(SvsmReqError::invalid_request());
122122
}
123+
// In TPM failure mode, _plat__RunCommand() redirects the response
124+
// pointer to an internal static buffer instead of writing into the
125+
// provided one.
126+
if response_ffi_p != response_ffi.as_mut_ptr() {
127+
core::ptr::copy(
128+
response_ffi_p,
129+
response_ffi.as_mut_ptr(),
130+
response_ffi_size as usize,
131+
);
132+
}
123133
response_ffi.set_len(response_ffi_size as usize);
124134
}
125135

0 commit comments

Comments
 (0)