Repository navigation
evetpm: never treat a TPM error as no disk key - #6691
Merged
eriknordmark merged 2 commits intoOct 9, 2026
Merged
Conversation
When the vault key is fetched, a TPM error while checking for the sealed disk key was read as "no key present", so EVE generated and sealed a fresh key over the existing one. Data encrypted with the old key, such as a reused etcd zvol after a kvm-to-k vault migration redo, then could not be opened by any key. The check now distinguishes an undefined NV index from a TPM error, retries the error twice with a log line per attempt, and fails the fetch rather than generating a key if it persists. An index that is defined but never written still counts as absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: eriknordmark <erik@zededa.com>
Fetching the vault key must not take a TPM error for an absent key, or it seals a fresh key over the one the vault is encrypted with. The tests put a proxy between EVE and the TPM simulator that fails the disk-key presence check while every other command, sealing included, keeps working. A transient failure must yield the sealed key, and a persistent one an error with the sealed key left in place. Against the earlier presence check, the transient case replaces the key. The proxy answers TPM_RC_NV_UNAVAILABLE rather than TPM_RC_RETRY because go-tpm retries TPM_RC_RETRY itself and never returns it to the caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: eriknordmark <erik@zededa.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6691 +/- ##
==========================================
+ Coverage 27.17% 27.47% +0.30%
==========================================
Files 524 534 +10
Lines 95907 97642 +1735
==========================================
+ Hits 26059 26829 +770
- Misses 67769 68542 +773
- Partials 2079 2271 +192 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
As it stands, LGTM. But given the title "never treat a TPM error as no disk key", I suggest fixing these two places too, either in this PR or upcoming one:
|
This was referenced Oct 30, 2026
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.
Description
Soak and stress testing tripped on this once, and it caused much confusion because a new key was generated.
When the vault key is fetched, a TPM error while checking whether a sealed disk key exists is read as "no key present", so EVE generates and seals a fresh key over the one the vault is encrypted with. Anything encrypted with the old key can then not be opened by any key. The check now tells an undefined NV index apart from a TPM error, retries the error twice with a log line per attempt, and fails the fetch rather than generating a key if the error persists. An index that is defined but never written still counts as absent.
How to test and validate this PR
Covered by the evetpm unit tests that run against swtpm in CI (
tests/tpm/prep-and-test.sh). A proxy between EVE and the TPM simulator fails the presence check while every other command, sealing included, keeps working:TestFetchSealedVaultKeyRetriesTPMError: a transient failure must return the sealed key. Without the fix this test fails, logging "neither legacy nor sealed disk key present, generating a fresh key".TestFetchSealedVaultKeyFailsOnPersistentTPMError: a persistent failure must return an error and leave the sealed key in place.TestDiskKeyPresentFailsOnTPMError: a TPM that cannot be opened is reported as an error, not as an absent key.Changelog notes
A transient TPM error at boot no longer replaces the vault's disk key with a new one.
PR Backports
The same presence check is in all four LTS branches.
Checklist
I've provided a proper description
I've added the proper documentation
I've tested my PR on amd64 device
I've tested my PR on arm64 device
I've written the test verification instructions
I've set the proper labels to this PR
I've checked the boxes above, or I've provided a good reason why I didn't
check them.
🤖 Generated with Claude Code