Skip to content
This repository was archived by the owner on Jul 2, 2023. It is now read-only.

Add Azure TDX (preview) support#221

Open
jepio wants to merge 2 commits intoconfidential-containers:mainfrom
jepio:azure-tdx-preview
Open

Add Azure TDX (preview) support#221
jepio wants to merge 2 commits intoconfidential-containers:mainfrom
jepio:azure-tdx-preview

Conversation

@jepio
Copy link
Member

@jepio jepio commented Jun 21, 2023

These changes were needed to get the TDX attestation to work on Azure.
Based on intel/trustauthority-client-for-go@c590bde.

@jepio jepio force-pushed the azure-tdx-preview branch from b2bcd3f to a178686 Compare June 21, 2023 15:46
jepio added 2 commits June 22, 2023 08:55
Marking get_evidence as async allows running async functions from an
attester. There are two motivators for this:

- TDX report->quote conversion can require an HTTP request, and it's a
  good idea to run that async.
- as we move to support the RATS passport model better the attester
  itself might need to talk to MAA or Amber to fetch an attestation
  token.

If get_evidence is not async, then it becomes tricky to use reqwest from
get_evidence. reqwest::blocking::Client panics because it internally
uses tokio and get_evidence is called from a tokio runtime.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
To get TDX attestation to work on Azure there are several changes
needed:
- the device node is called /dev/tdx_guest (upstream kernel name)
- quote generation uses the IMDS (instance metadata service) instead
  of tdvmcall or vsock. This also means we can't use tdx_att_get_quote
  which combines quote and report fetching
- no CCEL

Implement the evidence gathering in a sub-module attester, but keep it
within the TDX module because the evidence is fully compatible with the
existing TDX verifier.

It would be possible to use tdx_att_get_report, but calling an ioctl is
easy enough that it doesn't make sense to add the dependency on the
native library. The Intel library also seems to have an outdated
definition of the ioctl.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
@jepio jepio force-pushed the azure-tdx-preview branch from a178686 to 1fdab82 Compare June 22, 2023 08:56
}

pub(super) fn detect_platform() -> bool {
// check cpuid if we are in a Hyper-V guest
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// check cpuid if we are in a Hyper-V guest
// check cpuid if we are in a TD guest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually checking the hypervisor id so the comment is correct

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TDX module spec defines "TD guest" cpuid bit as well (I've tested it works in Azure). Would that be more robust check here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would defeat the purpose of the check. This check happens after we already checked for the presence of the tdx_guest device, which internally checks the cpuid bit (https://elixir.bootlin.com/linux/latest/source/drivers/virt/coco/tdx-guest/tdx-guest.c#L87).

The purpose of the check is to find out whether we're running in Azure (on Hyper-V) and if so - to use the tcp endpoint for report->quote conversion

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, makes sense 👍

Comment on lines +41 to +47
pub fn make_attester() -> Box<dyn Attester + Sync + Send> {
if az::detect_platform() {
Box::<az::TdxAttester>::default()
} else {
Box::<TdxAttester>::default()
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a nice idea for me to follow in the SGX attester, thanks

Comment on lines +17 to +23
// Upstream kernel exposes a /dev/tdx_guest device but Intel's lib expects
// /dev/tdx-guest
let paths = [
Path::new("/dev/tdx-attest"),
Path::new("/dev/tdx-guest"),
Path::new("/dev/tdx_guest"),
];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't like this approach after feeling the pain of fixing/using code using the non-standard paths in the SGX world. What would be the changes to force only /dev/tdx_guest usage here and get other parts fixed as early as possible (or have udev rules with symlinks)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGXDataCenterAttestationPrimitives would need to be fixed, because it uses a different ioctl/API to talk to /dev/tdx-guest than what was merged upstream. This also means symlinks won't simply work.

I think we're going to need to transition and phase out the older paths.

@mythi
Copy link

mythi commented Jun 22, 2023

btw, should this move to image-rs/attestation-agent?

@jepio
Copy link
Member Author

jepio commented Jun 22, 2023

btw, should this move to image-rs/attestation-agent?

Yes, good idea - i missed that the merge already happened.

@jepio
Copy link
Member Author

jepio commented Jun 22, 2023

Moved the PR here: confidential-containers/guest-components#170

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants