gcry_create_nonce after a snapshot or checkpoint restore
Yuxiang Ji
kurath0307 at icloud.com
Thu Oct 29 14:38:26 CET 2026
Hello,
Thank you for opening T8533. Some notes from the measurements, in case
they help with the design.
1. A reseed the application can ask for fits how a restore reaches
userspace today. Besides the VMClock device of Linux 7.0 (/dev/vmclock0,
which a process can map or poll, and which is root-only by default),
mainline Linux tells userspace nothing of a restore. The other signals
are the platform's own restore hooks (CRaC resources, Lambda SnapStart
runtime hooks, a CRIU action script), and a call made from such a hook
works with all of them.
2. On GCRYCTL_CLOSE_RANDOM_DEVICE: extending it would keep the API as it
is, and an application that already calls it before a fork would only
get an extra reseed. Its manual entry speaks of fork without exec, so
the new use would need a sentence there, or a control whose name says
reseed.
3. The fork that keeps the pid (unshare(CLONE_NEWPID) and fork() in a
process that is pid 1 of its namespace) needs no restore signal. If a
pthread_atfork child handler is acceptable in libgcrypt, one that marks
the nonce buffer for re-randomisation would cover it without a call from
the application.
4. A reseed right after a VM restore is as fresh as the guest's kernel
at that moment. With the vmgenid driver the kernel reseeds shortly after
the guest resumes, though on a loaded host a first read can still come
before it; without the driver the kernel continues from the saved state
until its own next scheduled reseed.
We can run a branch in the same cells as before (the fork family
including the unshare route, QEMU, Firecracker and CRIU) and post the
results to the ticket or the list.
Best regards,
Yuxiang Ji
NIIBE Yutaka <gniibe at fsij.org> wrote:
> If an RNG implementation and gcry_create_nonce in libgcrypt does not
> support VM-fork detection to automatically reseed, it's better for
> libgcrypt to offer a method for an application to control the situation.
>
> Suppose that an application wants to use VM-fork notifier to address
> this problem, and to reseed. Currently, with libgcrypt, there is no way
> to control gcry_create_nonce, for this case.
>
> If we won't introduce new API, I think that one way is using
> gcry_control with GCRYCTL_CLOSE_RANDOM_DEVICE, enhancing the semantics.
More information about the Gcrypt-devel
mailing list