Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/5.x] Cherry pick: Set and enforce VMPL in SNP attestation (#6583) #6584

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .snpcc_canary
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
...
/\/\d(-_-)b/\/\
--/\
----vmpl
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [5.0.8]

[5.0.8]: https://github.com/microsoft/CCF/releases/tag/ccf-5.0.8

- Set VMPL value when creating SNP attestations, and check VMPL value is in guest range when verifiying attestation, since recent [updates allow host-initiated attestations](https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/56860.pdf) (#6583).

## [5.0.7]

[5.0.7]: https://github.com/microsoft/CCF/releases/tag/ccf-5.0.7
Expand Down
14 changes: 14 additions & 0 deletions include/ccf/pal/attestation.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ namespace ccf::pal
fmt::format("SEV-SNP: Mask chip key must not be set"));
}

// Introduced in
// https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/56860.pdf
// The guest sets the VMPL field to a value from 0 thru 3 which indicates a
// request from the guest. For a Guest requested attestation report this
// field will contain the value (0-3). A Host requested attestation report
// will have a value of 0xffffffff. CCF current always sets VMPL to 0, and
// rejects non-guest values.
if (quote.vmpl > 3)
{
throw std::logic_error(fmt::format(
"SEV-SNP: VMPL for guest attestations must be in 0-3 range, not {}",
quote.vmpl));
}

report_data = SnpAttestationReportData(quote.report_data);
measurement = SnpAttestationMeasurement(quote.measurement);

Expand Down
2 changes: 1 addition & 1 deletion include/ccf/pal/snp_ioctl5.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace ccf::pal::snp::ioctl5
struct AttestationReq
{
uint8_t report_data[snp_attestation_report_data_size];
uint32_t vmpl;
uint32_t vmpl = 0;
uint8_t reserved[28];
};

Expand Down
2 changes: 1 addition & 1 deletion include/ccf/pal/snp_ioctl6.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ccf::pal::snp::ioctl6
struct AttestationReq
{
uint8_t report_data[snp_attestation_report_data_size];
uint32_t vmpl;
uint32_t vmpl = 0;
uint8_t reserved[28]; // needs to be zero
}; // aka snp_report_req in (linux) include/uapi/linux/sev-guest.h

Expand Down