-
Notifications
You must be signed in to change notification settings - Fork 283
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
RFC: improved UEFI Secure Boot certificates management in XAPI #4647
Comments
Instead of VM start the synchronization could also be performed exactly once on toolstack startup. That way you avoid race conditions where a VM rebooting might see a disappearing file (if your renames aren't atomic). |
If there's no reason to keep doing the synchronization on VM start, this looks good to me. Would it be needed also when a host joins a pool so that it inherits the pool certs? |
A merge of the certificates between the joiner and the pool would be needed, I think |
I don't see how we could do a "merge", so I think the pool certs should replace the joining host certs. |
- `Pool.set_uefi_certificates` is implemented and calls `Host.set_uefi_certificates` on all hosts - `Host.set_uefi_certificates` writes certificates on disks - On XAPI startup certificates stored in XAPI's `Host.uefi_certificates` are written on disks - When a host joins the pool `Host.set_uefi_certificates` is called with the certificates stored in XAPI's `Pool.uefi_certificates` This means: - At every XAPI startup the certificates in host disks are synced with XAPI's `Host.uefi_certificates` - When `Pool.set_uefi_certificates` is called all hosts are synced in XAPi and disks with XAPI's `Pool.uefi_certificates` - When `Host.set_uefi_certificates` is called the host certificates on disk are synced with XAPI's `Host.uefi_certificates` Also: `Host.set_uefi_certificates` no longer calls `Pool.set_uefi_certificates`, this requires changes in external libs (varstored, uefistored, etc) to set the pool's certificates: call `Pool.set_uefi_certificates`. See: xapi-project#4647 Signed-off-by: BenjiReis <benjamin.reis@vates.fr>
So, unless there are arguments against, we would like to completely bypass The reasons:
And this would also remove the need to do anything when a host joins a pool, as the certs will be written to disk when the toolstack restarts, directly read from the pool object. |
- `Pool.set_uefi_certificates` is implemented and writes the certificates on all its hosts' disks - `Host.set_uefi_certificates` is now deprecated and transmit the call to the pool method - `Host.uefi_certificates` is deprecated as well as it's getter, the value is not updated. - On XAPI startup certificates stored in XAPI's `Pool.uefi_certificates` are written on disks - When a host joins the pool's certificates are written on its disk. This means: - At every XAPI startup the certificates in host disks are synced with XAPI's `Pool.uefi_certificates` - When `Pool.set_uefi_certificates` is called all hosts are synced on their disks with XAPI's `Pool.uefi_certificates`. Also: `Host.set_uefi_certificates` calls should be replaced by `Pool.set_uefi_certificates`, this requires changes in external libs (varstored, uefistored, etc) to set the pool's certificates: call `Pool.set_uefi_certificates`. See: xapi-project#4647 Signed-off-by: BenjiReis <benjamin.reis@vates.fr>
Solved by merged of #4659 |
@stormi this can be closed. :) |
tl;dr
We would like to contribute a change that makes XAPI keep the local UEFI Secure Boot certificates that are stored on host disks in sync with the ones stored in XAPI's Pool object.
Context
UEFI Secureboot certificates (PK, KEK, db and dbx) are currently stored in several places in a Citrix Hypervisor or XCP-ng pool.
pool.uefi_certificates
. This is a tarball containing one to four.auth
files.PK.auth
which comes from thevarstored
RPM). BIOS hosts don't support Guest Secure Boot in CH.host.uefi_certificates
. To my knowledge, it's always in sync with the pool, and I don't know why it exists in the first place. Insight welcome on this!/usr/share/varstored
on Citrix Hypervisor, at/var/lib/uefistored
on XCP-ng to comply with the FHS as those are volatile files. I'm not entirely sure why those files exist in the first place but I assume this might be in an attempt to makevarstored
not too dependent on XAPI.varstored
(CH)/uefistored
(XCP-ng) and then never touched again in normal use. Some variables such as thedbx
may be modified later by the guest OS itself, but not by the hypervisor (outside user intervention).To a VM, the only source of truth for UEFI variables is its NVRAM store. All the other levels of certificate storage are just a convenience to populate the NVRAM store of new VMs at first boot with usable certificates.
All the layers described above inherit from each other in some way:
In theory, in current implementation of XAPI, certs are not meant to be inherited from Pool (XAPI) to host disk after they have been inherited once.
In practice, there is a bug in Citrix Hypervisor 8.2 that causes the certificates to be rewritten to disk every time a UEFI VM starts. @benjamreis contributed a fix for that recently: #4624
The issue
Despite it was a bug, the fact that the certificates were written to disk each time a UEFI VM starts was interesting to us: it would keep the certs on disk in sync with the Pool certs in XAPI 🎉.
On Citrix Hypervisor, this might not be really important, as certs are read from the master host's firmware at first boot and not modified afterwards (I'm not sure... Maybe they're updated if the firmware is updated. I haven't checked that part.).
But on XCP-ng, it is important because we support modifying the pool's UEFI certificates at will. For example, users may update the
dbx
(revocation database) to the latest provided by Microsoft to enhance the overall security on their pool for new VMs (for new VMs only... As we said earlier, VMs that already have certificates live their own "certificate life").So @benjamreis' fix is actually a functional regression for us :D
Proposal #1
The current "XAPI to host disk sync" algorigthm is as follows:
The current buggy behaviour in CH 8.2, fixed on master, is:
Note: this does not remove existing files that are absent from XAPI, though. Files are just overwritten if they exist.
The new behaviour we would like to contribute is:
If we agree on this solution, we will contribute a PR to implement it.
Proposal #2
In my view, a better but heavier solution would be: get rid of the files on disk, completely. Let varstored/uefistored get them from XAPI directly when needed (that is, when booting up a UEFI VM that doesn't have certificates yet).
This would remove a layer that seems to be causing more issues than it solves (I may be wrong on this statement).
I'm not sure this would make varstored more dependent on XAPI, as varstored supports several back-ends. Only the XAPI back-end would be dependent on XAPI but it already is as far as I can tell.
Maybe we could also remove the certificates that are stored at host level in XAPI. Here again I can be wrong, but I doubt they add a real value. After all, the certs in Pool/Host levels are only meant to bootstrap new VMs. If users need to use specific certificates for specific VMs, they still have complete control over the certs in VMs anyway (using the
varstored-setup
andvarstore-set
commands).I can't promise our planning would allow us to contribute such changes but I would like to discuss them at least.
The text was updated successfully, but these errors were encountered: