Skip to content

lcfs-fsverity: fix root_hash for zero-length files - #445

Merged
cgwalters merged 1 commit into
composefs:mainfrom
cgwalters:digest-empty
Jul 28, 2026
Merged

cgwalters merged 1 commit into
composefs:mainfrom
cgwalters:digest-empty

Conversation

@cgwalters

Copy link
Copy Markdown
Contributor

lcfs_fsverity_context_get_digest() unconditionally zero-padded and hashed a full Merkle tree block to produce root_hash, even for zero-length files. Per the fs-verity on-disk format, an empty file has zero Merkle tree blocks, so root_hash must be all-zero bytes instead.

This meant composefs-info measure-file (and any direct caller of lcfs_fsverity_context_get_digest with empty input) reported a digest the kernel, fsverity-utils, and composefs-rs's independent reimplementation can never produce, even though composefs images themselves are unaffected since they never reference empty backing objects.

Assisted-by: https://github.com/cgwalters/cgwalters#llms
Closes: #442

lcfs_fsverity_context_get_digest() unconditionally zero-padded and
hashed a full Merkle tree block to produce root_hash, even for
zero-length files. Per the fs-verity on-disk format, an empty file has
zero Merkle tree blocks, so root_hash must be all-zero bytes instead.

This meant composefs-info measure-file (and any direct caller of
lcfs_fsverity_context_get_digest with empty input) reported a digest
the kernel, fsverity-utils, and composefs-rs's independent
reimplementation can never produce, even though composefs images
themselves are unaffected since they never reference empty backing
objects.

Assisted-by: https://github.com/cgwalters/cgwalters#llms
Closes: composefs#442
Signed-off-by: Colin Walters <[email protected]>

@jeckersb jeckersb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cgwalters
cgwalters merged commit 36465ad into composefs:main Jul 28, 2026
10 checks passed
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.

composefs-info measure-file reports a wrong fs-verity digest for empty files

2 participants