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

Hermit is not currently supported by getrandom #199

Closed
josephlr opened this issue Jan 17, 2021 · 4 comments
Closed

Hermit is not currently supported by getrandom #199

josephlr opened this issue Jan 17, 2021 · 4 comments
Labels
enhancement New feature or request waiting on upstream Waiting for upstream changes in an external project

Comments

@josephlr
Copy link
Member

Hermitcore is a unikernel OS, written in Rust, with Tier 3 libstd support for aarch64-unknown-hermit and x86_64-unknown-hermit.

See #198 and #183 for previous attempts at this.

Other PRs/issues of note:

We should figure out:

  • How/when we want to add support to getrandom
  • Is the existing secure_rand64 API sufficient?
  • Hermit's RNG apis current don't work on aarch64, is that an issue?
@newpavlov
Copy link
Member

Hermit's RNG apis current don't work on aarch64, is that an issue?

Yes, it's an issue, since it causes workarounds like this. In user code it can be worked around slightly more elegantly using the custom feature, but we can not rely on it in std. Note that currently Hermit's std simply uses a constant seed on all targets.

@josephlr
Copy link
Member Author

josephlr commented Apr 29, 2021

I think the most reasonable approach here is the following:

  1. Simply add support for hermit using their secure_rand64 API and the hermit-abi crate. Given that hermit is a unikernel, I don't see any reason to push them for a buffer-based API (so Improve randomness syscalls hermit-os/kernel#143 isn't too important).
  2. Keep the aarch64+hermit workaround in Use getrandom for generating HashMap seed rust-lang/rust#80149 for now (to keep existing behavior).
  3. Eventually, change std's use of getrandom to emit a fallback seed if the getrandom function fails. Then, a user on aarch64-unknown-hermit will:
    • Call getrandom::getrandom, which will call secure_rand64, which will fail, causing the function to return an error.
    • The std implementation will then return a fallback seed, preserving the existing behavior.

@newpavlov
Copy link
Member

Given that hermit is a unikernel, I don't see any reason to push them for a buffer-based API

Buffer-based API is not important here, it's the fact that Hermit randomness API always fails on ARM targets. To say the least, it's not normal and should be fixed.

The std implementation will then return a fallback seed, preserving the existing behavior.

I don't think it's a good behavior for all targets. It effectively means introduction of potential silent failures just because one target has an always failing randomness source.

@josephlr josephlr added enhancement New feature or request waiting on upstream Waiting for upstream changes in an external project labels Oct 23, 2022
@josephlr
Copy link
Member Author

josephlr commented Feb 9, 2023

Fixed by #333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting on upstream Waiting for upstream changes in an external project
Projects
None yet
Development

No branches or pull requests

2 participants