Skip to content

Hermit is not currently supported by getrandom #199

Closed

Description

@josephlr

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?

Activity

  1. newpavlov commented on Jan 17, 2021

    @newpavlov
    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.

  2. josephlr commented on Apr 29, 2021

    @josephlr
    MemberAuthor

    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.
  3. newpavlov commented on Apr 30, 2021

    @newpavlov
    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.

  4. josephlr commented on Feb 9, 2023

    @josephlr
    MemberAuthor

    Fixed by #333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwaiting on upstreamWaiting for upstream changes in an external project

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions