Repository navigation
hash-signature (3): deploy and open verity root hash signature partitions - #836
Draft
bfjelds (bfjelds) wants to merge 6 commits into
Draft
bfjelds (bfjelds) wants to merge 6 commits into
bfjelds (bfjelds) wants to merge 6 commits into
Conversation
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-3-engine
branch
from
October 8, 2026 16:39
965932e to
078cfed
Compare
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-2-cosi
branch
from
October 8, 2026 16:39
1d1a60b to
65226af
Compare
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-3-engine
branch
from
October 8, 2026 16:58
078cfed to
fe4e3e3
Compare
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-2-cosi
branch
2 times, most recently
from
October 8, 2026 17:08
1021d24 to
9ca9233
Compare
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-3-engine
branch
from
October 8, 2026 17:08
fe4e3e3 to
75b556c
Compare
Implements install/update support for the optional verity root hash signature partition introduced in the previous two PRs of this stack. - `deploy_images` streams the signature partition's content from the OS image when both the image and the Host Configuration declare a signature device; errors if only one side declares it. - `setup_verity_devices` prefers the new declarative signature partition when `VerityDevice.signature_device_id` is set: reads the PKCS#7/DER signature directly from the raw block device (no mount needed, since the DER encoding is self-delimiting), writes it to a temp file, and opens the verity device with `veritysetup open --root-hash-signature=...`. Falls back to the existing `internal_params.veritySignaturePaths` file-based mechanism, then to a plain open, preserving prior behavior when no signature partition is configured. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Construct the special storage-graph reference connecting a verity device to its optional root hash signature device. This activates the validation rules added in the HostConfig API PR (restricting the signature device to a LinuxGeneric partition, enforcing homogeneous partition types, etc.), and is paired with the engine-side install/update support in this PR.
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-2-cosi
branch
from
October 8, 2026 17:51
9ca9233 to
6da83e1
Compare
bfjelds (bfjelds)
force-pushed
the
user/bfjelds/verity-roothash-sig-3-engine
branch
from
October 8, 2026 17:51
75b556c to
b1e1993
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Reading an entire potentially grow-sized partition into memory risks exhausting memory and temporary storage.
2 open findings
What changed in this PR
Adds deployment and activation support for optional dm-verity root-hash signature partitions.
Changes:
- Deploys signature images with verity data and hash images.
- Opens verity devices using signatures read from dedicated partitions.
- Adds signature partitions to storage dependency graphs.
| File | Description |
|---|---|
crates/trident/src/engine/storage/verity.rs |
Reads partition signatures and opens signed verity devices. |
crates/trident/src/engine/storage/image.rs |
Deploys signature partition images. |
crates/trident_api/src/config/host/storage/storage_graph/references.rs |
Activates the signature reference kind. |
crates/trident_api/src/config/host/storage/storage_graph/node.rs |
Adds configured signature devices to graph references. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 8, 2026
Addresses review feedback on PR #836: - Bound the number of bytes read from a dedicated verity root hash signature partition (extracted into read_signature_partition_bytes) instead of fs::read()-ing the whole block device. A Grow-sized signature partition can no longer be read entirely into memory; oversized partitions are now rejected with a clear error. - Add unit tests: read_signature_partition_bytes bounds enforcement, and a setup_verity_devices test proving the declarative hash_signature_device_id path takes precedence over the legacy veritySignaturePaths internal parameter. While adding that precedence test, found and fixed a latent bug it would otherwise have hit: BlkDevReferrerKind::VerityDevice::valid_target_count() was still hardcoded to exactly 2 targets, so any verity device that actually sets hash_signature_device_id (the whole point of this feature) fails storage graph validation with InvalidTargetCount before ever reaching the engine. Widened to accept 2-3 targets. All existing trident_api/trident unit tests (195 + 407) still pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…setup Addresses review feedback on PR #836 (and supersedes my own earlier fix to the same code, which was still wrong): open_verity_device_with_signature_partition used to read the signature partition's bytes into memory (bounded by an arbitrary 1 MiB cap) and copy them into a temporary file for veritysetup. That cap was itself broken: block-device reads don't EOF until the partition ends, and deployment doesn't truncate/zero the tail beyond the real image bytes, so any real signature partition sized (e.g. via PartitionSize::Grow) past 1 MiB would be rejected even though the actual DER payload inside it is tiny. The deeper problem was reading the bytes at all. `veritysetup --root-hash-signature=FILE` and the existing open_with_signature() wrapper just take a path - there's no distinction between a regular file and a block device special file, and both `open()`/`read()` identically either way. The PKCS#7/DER blob is self-delimiting, so whatever parses it stops at the structurally-defined length regardless of trailing zero-padding. Trident's job for this partition should stop exactly where it stops for the hash partition: deploy the COSI image bytes onto the right partition (already handled uniformly for every image via deploy_os_image_file's uncompressed_size-bounded stream), and nothing else - no read-back, no cap, no temp file. Deleted read_signature_partition_bytes and the temp-file copy entirely; the signature partition's resolved device path is now passed directly to open_with_signature, exactly like data_device_path/hash_device_path already are. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d61c42e7-3c43-4fe5-8c89-89d38ff9528b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d61c42e7-3c43-4fe5-8c89-89d38ff9528b
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Third and final PR in a 3-part stack implementing an optional dm-verity root hash signature partition. Builds on #835.
This PR implements install/update support: Trident can now deploy a COSI's signature partition content and use it when opening verity devices.
Changes
deploy_imagesstreams the signature partition's content from the OS image when both the image and the Host Configuration declare a signature device. Errors clearly if only one side declares it (misconfiguration).setup_verity_devicesprefers the new declarative signature partition whenVerityDevice.signature_device_idis set:veritysetup open --root-hash-signature=....internal_params.veritySignaturePathsfile-based mechanism, then to a plainopen(), preserving behavior when no signature partition is configured.Stack
Testing