Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unconditional getrandom syscall creating a WasiCtx #5244

Merged

Conversation

alexcrichton
Copy link
Member

This commit updates the default random context inserted into a WasiCtxt to be seeded from thread_rng rather than the system's entropy. This avoids an unconditional syscall on the creation of all WasiCtx structures shouldn't reduce the quality of the random numbers produced.

This commit updates the default random context inserted into a
`WasiCtxt` to be seeded from `thread_rng` rather than the system's
entropy. This avoids an unconditional syscall on the creation of all
`WasiCtx` structures shouldn't reduce the quality of the random numbers
produced.
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Nov 10, 2022
@github-actions
Copy link

Subscribe to Label Action

cc @kubkon

This issue or pull request has been labeled: "wasi"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 10, 2022

It does reduce quality when forking processes or entire vm's. For cloning vm's acpi allows the virtual machine monitor to tell the vm that a clone has happened, which on linux causes the system csprng to be reseeded. See https://lwn.net/Articles/887207/

@alexcrichton
Copy link
Member Author

Wasmtime hasn't really been written for fork-safety, and otherwise fork-safety seems like it would be part of the rand or cap-rand crate, if anything, so I'm going to go ahead and merge this.

@alexcrichton alexcrichton merged commit 1f09954 into bytecodealliance:main Nov 10, 2022
@alexcrichton alexcrichton deleted the wasi-less-getrandom branch November 10, 2022 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants