ateom-microvm: reseed the guest CRNG on restore - #1524
Open
eliranw wants to merge 2 commits into
Open
Conversation
A restored microVM guest resumes with its kernel entropy pool frozen in the snapshot, so two actors restored from the same snapshot start with the same CRNG state and can return duplicate random values until the kernel reseeds on its own. On a live restore that window was measured at up to about 36ms after resume. Cloud Hypervisor exposes no VmGenID device to signal the guest, so ateom reseeds it directly. On each restore it generates a fresh 32-byte nonce and passes it to the kata-agent's ReseedRandomDev RPC, which mixes it into the guest CRNG. Because the nonce differs per restore, clones diverge regardless of when the kernel would have reseeded on its own. This covers the kernel CRNG only. Userspace PRNG seeds in checkpointed app memory remain a workload concern. The reseed lands a few milliseconds after the vCPUs resume, so the first read or two can still be frozen. A follow-up can freeze the workload across the reseed to close that fully. Signed-off-by: Eliran Wolff <[email protected]>
…reseed Add a TODO on the restore reseed path pointing at a Cloud Hypervisor VmGenID device as the eventual replacement. A VmGenID acts before the vCPUs resume, so the guest kernel reseeds itself with no host round-trip and no post-Resume race, at which point the agent-driven reseed can be dropped. Signed-off-by: Eliran Wolff <[email protected]>
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.
What
On the microVM restore path, ateom reseeds the guest kernel CRNG with fresh entropy through the kata-agent's ReseedRandomDev RPC, right after the guest resumes.
This implements the guest RNG reseed on restore that #1449 calls out as an unfiled gap (its Strategy 2, inject freshness at restore). Scoped to the kernel CRNG on the microVM runtime, so it does not close #1449.
Why
Two actors restored from the same snapshot start with the same frozen CRNG state. The kernel reseeds from ambient entropy on its own, but not immediately. Measured on a live restore, two clones kept returning identical /proc/sys/kernel/random/uuid values for up to about 36ms after resume before that happened. A workload reading randomness in its first moments after resume can land in that window and get duplicate values across clones.
Cloud Hypervisor has no VmGenID device to signal the guest, so ateom reseeds it directly. On each restore it hands a fresh 32-byte nonce to the kata-agent, which mixes it into the guest CRNG. The nonce differs per restore, so clones diverge regardless of the kernel's own timing. The kata-agent already exposes this RPC, so the change is host-side in ateom.
Behavior
Fires on every restore (golden cold-start and resume alike). Cold boot does not need it. Best-effort: a failure is logged, not fatal, so a transient agent error never fails an otherwise good restore.
Scope and limits
Testing