Skip to content

doc: extend the fork safety guidance to snapshot and checkpoint restores - #6049

Merged
randombit merged 1 commit into
randombit:masterfrom
KurathSec:stutter-rng-doc
Oct 20, 2026
Merged

randombit merged 1 commit into
randombit:masterfrom
KurathSec:stutter-rng-doc

Conversation

@KurathSec

Copy link
Copy Markdown
Contributor

Documentation only: a short section after "Fork Safety" in doc/api_ref/rng.rst on snapshot and
checkpoint restores, as discussed with Jack by mail.

A process or a virtual machine restored from a saved image (a VM snapshot, a CRIU checkpoint, a
function resumed from an image) is duplicated without a fork: the process ID does not change, so
the pid and fork-generation checks of Stateful_RNG see nothing and every copy continues from the
state in the image. AutoSeeded_RNG's per-request draw from the system RNG keeps the output
distinct between the copies where the operating system's own generator was reseeded at the
restore (on Linux, when the hypervisor provides a VM generation ID and the guest kernel carries
the vmgenid driver); the internal state is the image's until the next reseed. Measured: two
continuations of one QEMU or Firecracker snapshot print distinct AutoSeeded_RNG output while a
generate call with a fixed additional input shows the first draw after the restore coming from
the duplicated state; in a guest whose kernel had no restore signal the first block repeated with
the kernel's.

The section recommends an explicit reseed after a restore, as the fork section does after a
fork, and names the signals a platform offers (a restore hook; on Linux 7.0 and later the
vm_generation_counter of the VMClock page, /dev/vmclock0). Please edit freely.

A process or a virtual machine restored from a saved image is duplicated
without a fork: the process ID does not change, so the pid and fork
generation checks of Stateful_RNG see nothing and every copy continues
from the state in the image. AutoSeeded_RNG's per-request draw from the
system RNG keeps the output distinct where the operating system's
generator was itself reseeded at the restore; the internal state is the
image's until the next reseed. Say so beside the fork safety section,
recommend an explicit reseed after a restore as after a fork, and name
the signals a platform offers (a restore hook; on Linux 7.0 and later the
VMClock page's vm_generation_counter).
Copilot AI balanced review requested due to automatic review settings October 20, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@randombit randombit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM thank you

@randombit
randombit merged commit 5715786 into randombit:master Oct 20, 2026
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.

3 participants