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

Secure boot support for raspberrypi4-ioboard-sb #1117

Merged
merged 19 commits into from
May 20, 2024
Merged

Conversation

alexgg
Copy link
Contributor

@alexgg alexgg commented Apr 5, 2024

No description provided.

@alexgg alexgg marked this pull request as draft April 5, 2024 13:53
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch 3 times, most recently from 87166ab to e9f21d5 Compare April 15, 2024 15:23
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch 5 times, most recently from 2f279fe to a4de8e0 Compare April 22, 2024 10:16
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch 3 times, most recently from a8a612a to 75258f5 Compare May 3, 2024 10:05
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch 2 times, most recently from 20f30b4 to 17fbe48 Compare May 9, 2024 12:33
@alexgg alexgg changed the title [WIP] Secure boot support for raspberrypi4-ioboard-sb Secure boot support for raspberrypi4-ioboard-sb May 12, 2024
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch 4 times, most recently from ca5bdea to 86823d3 Compare May 14, 2024 11:49
@alexgg alexgg marked this pull request as ready for review May 14, 2024 11:49
@alexgg alexgg requested a review from a team May 14, 2024 11:50
@flowzone-app flowzone-app bot enabled auto-merge May 14, 2024 11:53
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch 3 times, most recently from 8c92728 to 67e2c73 Compare May 16, 2024 11:53
alexgg added 5 commits May 17, 2024 15:45
Changelog-entry: add secure boot enabled Raspberrypicm4 ioboard support
Signed-off-by: Alex Gonzalez <[email protected]>
Changelogs-entry: add class for RPI image signing
Signed-off-by: Alex Gonzalez <[email protected]>
This will be used in provisioning and copied to the SPI EEPROM.

Changelog-entry: Deploy RPI public key
Signed-off-by: Alex Gonzalez <[email protected]>
Adds an os-helper-otp file that contains the shared interface to the OTP.

Changelog-entry: add public interface to OTP
Signed-off-by: Alex Gonzalez <[email protected]>
This helper file is used to customize HUP and share variables with the
flasher script.

Changelog-entry: add os-helpers-sb
Signed-off-by: Alex Gonzalez <[email protected]>
alexgg added 14 commits May 17, 2024 15:45
A secured device cannot have the EEPROM updated using this
mechanism. A self-update is needed.

Change-type: patch
Signed-off-by: Alex Gonzalez <[email protected]>
Making balena-image-flasher buildable for secure boot use cases.

Also, place EEPROM binaries in the boot partition so they can be used in
the provisioning process.

Changelog-entry: Support flasher image for secure boot use cases.
Signed-off-by: Alex Gonzalez <[email protected]>
Include the files with the secureboot and disk encryption interface.

Changelog-entry: provide secure boot and disk encryption abstraction
Signed-off-by: Alex Gonzalez <[email protected]>
Allow to update the SPI EEPROM from the flasher images as this is
required to enable secure boot as part of provisioning.

Change-type: patch
Signed-off-by: Alex Gonzalez <[email protected]>
Changelog-entry: specialize cryptsetup module for RPI
Signed-off-by: Alex Gonzalez <[email protected]>
Add a mount service for the unencrypted boot partition.

Changelog-entry: add mount service for the unencrypted boot partition
Signed-off-by: Alex Gonzalez <[email protected]>
Duplicate 1-bootfiles into 2-rpifiles so that the bootfiles are
installed in two passes, one for the non-encrypted boot partition and
a second one for the encrypted boot partition.

The 1-bootfiles will differentiate based on the script name whether
to target the encrypted or non-encrypted partittions for file installation.

Changelog-entry: customize hostOS update script for secure boot
Signed-off-by: Alex Gonzalez <[email protected]>
Inherit the use of OS_KERNEL_CMDLINE and OS_KERNEL_SECUREBOOT_CMDLINE
from balenaOS distro settings.

Also, use early console settings for osdev images.

Changelog-entry: use distribution's kernel command line variables
Signed-off-by: Alex Gonzalez <[email protected]>
Increase the default size to support building signed images.

Change-type: patch
Signed-off-by: Alex Gonzalez <[email protected]>
When performing a hostOS update we perform atomic writes of individual
files, that is, first we copy a new file, and then we rename.

The rename operation is atomic on some filesystems like ext4, but on
vfat it has not been atomic until Linux kernel v6.0.

Hence, balenaOS uses a `fatrw` library that keeps a checksummed copy of
the file until the rename completes and can be verified. Unfortunately,
for hostOS updates `fatrw` will fallback to a non-atomic rename if there
is not enough space to keep a checksummed copy of the file. This will
stop being a problem once a >6.0 kernel is used.

Now, a secure boot enabled CM4/RPI4 required a single boot.img that
contains all the essential boot firmware. This contains the balena
bootloader and its initramfs that needs packages to mount encrypted
file systems. Basically, the size of the balena booloader increases to
around 50M, and the size of boot.img to around 60M, so we need at least
double that in order to perform atomic updates of this file.

Changelog-entry: increase the boot partition size for CM4 to support secure boot
Signed-off-by: Alex Gonzalez <[email protected]>
With the definition of SIGN_API the initramfs image has increased. This
still fits in the existing partition layout so there is really no other
implications.

Changelog-entry: adjust initramfs size for RPI4
Signed-off-by: Alex Gonzalez <[email protected]>
Changelog-entry: add usbboot native recipe
Signed-off-by: Alex Gonzalez <[email protected]>
This deploys the signed artifacts needed for a locked device
reprovisioning.

Changelog-entry: add usbboot native dependency
Signed-off-by: Alex Gonzalez <[email protected]>
Changelog-entry: add secure boot and disk encryption documentation
Signed-off-by: Alex Gonzalez <[email protected]>
@alexgg alexgg force-pushed the alexgg/sb-cm4ioboard branch from 67e2c73 to 82ea457 Compare May 17, 2024 13:45
@alexgg
Copy link
Contributor Author

alexgg commented May 20, 2024

lgtm

@alexgg alexgg disabled auto-merge May 20, 2024 08:25
@alexgg
Copy link
Contributor Author

alexgg commented May 20, 2024

Manual merge without the test-raspberrypi4-unipi-neuron test passed as it has not passed for a few months.

@alexgg alexgg merged commit bc3f9fe into master May 20, 2024
49 of 59 checks passed
@alexgg alexgg deleted the alexgg/sb-cm4ioboard branch May 20, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant