vboot: Upgrade to uguid 1.0

BUG=None
TEST=cargo xtask check

Change-Id: Iefaf0c22ee1994b4560a769adf49bc9a30b96c57
Reviewed-on: https://chromium-review.googlesource.com/c/crdyboot/+/3838827
Reviewed-by: Steve Kendall <skend@google.com>
Tested-by: Nicholas Bishop <nicholasbishop@google.com>
Auto-Submit: Nicholas Bishop <nicholasbishop@google.com>
Commit-Queue: Steve Kendall <skend@google.com>
2 files changed
tree: 085d52fc8a4a20dc37af08681d6d67ad9e2ecf1b
  1. .cargo/
  2. crdyboot/
  3. enroller/
  4. libcrdy/
  5. third_party/
  6. vboot/
  7. workspace/
  8. xtask/
  9. .deny.toml
  10. .gitignore
  11. .gitmodules
  12. .rustfmt.toml
  13. Cargo.lock
  14. Cargo.toml
  15. LICENSE
  16. OWNERS
  17. README.md
README.md

crdyboot

Pronounced CUR-dee-boot.

This is a UEFI bootloader for CloudReady. Crdyboot handles loading, verifying, and running the Linux kernel.

Goals:

  • Well documented and as simple as possible.
  • Ensure that when secure boot is enabled, dm-verity is enabled for the rootfs. (Note that this can only be fully verified if using custom Secure Boot keys, otherwise a different OS signed with the Microsoft keys could be used to avoid verifying the rootfs.)
  • Use UEFI features as little as possible. We need to run on a lot of hardware, and not all UEFI implementations work well.
  • Use the ChromeOS GPT-attribute mechanism for determining which kernel to boot.
  • Use the ChromeOS kernel partitions rather than loading the kernel from the EFI partition. The kernel partitions include both the kernel data and command-line, as well as data structures to verify the signature of everything being loaded.
  • Verify the signature of everything loaded from the kernel partition.
  • Only support 64-bit CPUs, but support both 32- and 64-bit UEFI environments.

License

BSD

Code layout

The vboot subdirectory is a no_std library that handles loading and verifying the kernel. Internally it uses the LoadKernel function from third_party/vboot_reference. This crate can be built for the host target so that tests can run.

The crdyboot subdirectory contains the actual bootloader. It can only be built for the x86_64-unknown-uefi and i686-unknown-uefi targets.

The xtask subdirectory contains a single binary that is used by the various xtask commands shown below.

The enroller subdirectory contains a small UEFI application that enrolls a test key in the PK, KEK, and db variables. This only works if the machine is in secure boot custom mode.

Dependencies

Install nightly Rust:

cargo xtask install-toolchain

Headers needed for compiling vboot_reference:

sudo apt install libflashrom-dev

Other tools used for image signing and running in a VM:

sudo apt install efitools gdisk ovmf ovmf-ia32 qemu-system-x86 sbsigntool

After installing qemu, add your user to the kvm group. You will need to log out and back in for this to take effect:

sudo adduser ${USER} kvm

Building and testing

Before running any other commands in the repository, run this setup command:

cargo xtask setup <reven-verity-image-path>

This will copy the reven image to a local directory and run various setup commands. The image must have rootfs verification enabled (i.e. build_image must be run without -r or --no-enable-rootfs-verification). Any kind of image (base, dev, or test) is allowed.

To check formatting, lint, test, and build both vboot and crdyboot:

cargo xtask check

To build crdyboot for both 64-bit and 32-bit UEFI targets:

cargo xtask build

To copy the latest crdyboot build to the image:

cargo xtask update-disk

Then run it in QEMU:

cargo xtask qemu [--ia32] [--secure-boot]

Some additional build options can be set in crdyboot.toml (in the root of the repo). This file will be created automatically if it doesn't already exist by copying xtask/default.toml. The defaults are appropriate for development. In a release build, verbose logging and the test key should be turned off.

Testing on real hardware

To test secure boot with real hardware you will need to enroll custom keys. Write workspace/enroller.bin to a USB, and write workspace/disk.bin to a second USB, e.g. using writedisk.

Boot the DUT and enter the boot setup. Find the secure boot settings and change it to setup mode. (The details will vary from one vendor to another.)

Plug in the enroller USB and reboot. Use the boot menu to select the USB and wait for it to complete.

Unplug the enroller USB and plug in the cloudready USB, then reboot. Use the boot menu to select the USB.

Developer notes

An older pure-Rust version can be found in the pure-rust-20210729 branch. Since then we have switched to building the C vboot library and loading/verifying the kernel through that library.