-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Background:
dm-verity support was recently contributed12 to the barebox bootloader with an eye towards leveraging the discoverable partition specification to associate the rootfs partition with verity hash data and signature.
The embeded systems that barebox is deployed on usually have two rootfs partitions (A/B), which barebox chooses between on boot up.
In future configurations with dm-verity, barebox would verify the root hash for the active rootfs partition, boot the kernel image from it and pass along the root hash via the kernel command line.
Problem:
The discoverable partition specification associates a rootfs partition with its verity partition by means of the GPT Partition UUID:
- The root partition UUID is the first 128 bits of the root hash
- The root verity partition (dm-verity superblock followed by hash data) partition UUID is the last 128 bits of the root hash
In A/B update systems, we run into a corner case when the same update has been installed twice back to back:
We then end up with two root partitions with the same partition UUID as well as two verity partition also with the same partition UUID.
This violates the GPT specification as partition UUIDs are meant to be unique and this will result in misbehavior,
e.g., if the bootloader fixes up root=PARTUUID=... into the kernel command line, the kernel may end up locating and mounting a different rootfs partition than the bootloader.
Likewise /dev/disk/by-uuid/ would also run into conflicts.
A/B issues also arise with the verity signature partition: The partition contains the root hash, but no further info to deterministically associate it with the corresponding root and verity partitions.
I would argue that the core issue here is non-unique partition UUIDs and it would be good to have a resolution for this.
Possible approaches:
In order to allow partition UUIDs to be unique/randomized again, we will need an alternative scheme to associate rootfs with verity data and signature (let's call each of these a group). Candidates for defining groups could be:
- Order: The specification could prescribe a scheme where partitions in the group should follow each other in a specific order. GPT allows for on-disk order to differ from table order, so this does not preclude resizing partitions for example.
- Name: For the Type UUIDs defined by the spec, a naming scheme could be prescribed to indicate groups
- Attributes: The spec leaves 13/16 Type-specific attribute bits undefined, which could be used to encode a fixed number of groups. Alternatively, it could also be useful in combination with one of the two approaches above to ensure backwards compatibility.
Interested in hearing your thoughts.