Skip to content

IaaS ADR on providing virtio-rng entropy source #234

Closed

Description

@garloff

As an SCS IaaS user, I want to rely on having enough entropy in the virtual machines that are started.
For this I configure virtio-rng guest driver in the VM and expect virtio-rng to be supported from the host (hypervisor).

Definition of Done:

  • A standard for entropy in SCS environments exists
  • All acceptance criteria are met

Activity

  1. added
    IaaS
    SCS is standardized
    standards
    on Dec 8, 2022
  2. garloff commented on Dec 8, 2022

    @garloff
    MemberAuthor

    Notes:

    • Maybe we should make this a SHOULD, as we don't want to mandate KVM as hypervisor and possiby not all alternative hypervisors support virtio-rng?
    • We could als require (MUST) that entropy is injected via metadata always
    • IF we don't have virtio-rng, we MUST provide reasonable fallback. I would suggest in addition to the entropy injection via metadata that we require CPU hardware RNG capability then. (However, to consume the latter, the images would need to start havegd or rngd included and configured to start -- this would need investigation ...) Needs discussion ...
  3. moved this from Backlog to Blocked / On hold in Sovereign Cloud Stackon Feb 10, 2023
  4. matfechner commented on Feb 10, 2023

    @matfechner
  5. moved this from Blocked / On hold to Doing in Sovereign Cloud Stackon Feb 14, 2023
  6. fkr commented on Feb 14, 2023

    @fkr
    Member

    @matfechner imho the document from SovereignCloudStack/standards#210 does not address the requirements from this issue, since the fallback case is not elaborated on.

  7. garloff commented on Feb 14, 2023

    @garloff
    MemberAuthor

    With the image metadata, enabling hw_rng:virtio, I believe that we have TWO potential good entropy sources in the VM.
    (1) The virtio-rng driver in the guest can get entropy from the host. (Does this require rng-utils?)
    How the host (hypervisor) generates entropy depends ... it may use the traditional IRQ jitter etc. or use the CPU RNG in addition. This option requires trusting the host and its operators.
    (2) The RDRAND and RDSEED instructions are not privileged and work fine in VMs. To use it the guest must have rng-utils installed and started. (Should we consider having vendor_data doing this by default?). This requires trusting the CPU vendor. It is not available on very old x86 CPUs (pre-Ivy-Bridge, pre-Zen).

    Option (1) is only available on hypervisors providing virtio-rng. This works nicely on kvm, and probably also xen, not so sure about others (hyper-v, esx, ...). So we would need to require (2) to be working there.

    We get some initial entropy also injected via the metadata and cloud-init uses it to feed the initial entropy pool. We should require this as well, because some images may not have rng-utils enabled.

  8. fkr commented on Feb 24, 2023

    @fkr
    Member

    Option (1) is only available on hypervisors providing virtio-rng. This works nicely on kvm, and probably also xen, not so sure about others (hyper-v, esx, ...). So we would need to require (2) to be working there.

    This ADR by @matfechner is in regards to the IaaS reference implementation (from my understanding and the title of the issue etc.), shouldn't we just focus on whats in the IaaS reference implementation then? (eg. kvm)

  9. matfechner commented on Mar 7, 2023

    @matfechner

    @fkr but the haveged is as method under item 1.2.1 for Hyper-V, Xen or VMware is also documented, as well. That is an accepted method that work since years in F5 applicances, etc.

  10. fkr commented on Mar 14, 2023

    @fkr
    Member
  11. 3 remaining items

  12. added
    Sprint Bratislava
    on May 17, 2023
  13. added this to the R5 (v6.0.0) milestone on May 17, 2023
  14. added
    Sprint Copenhagen
    on May 17, 2023
  15. mbuechse commented on May 23, 2023

    @mbuechse

    I'm currently working with @cah-hbaum on the tests for this standard (see standards/#268). Hannes and I are having trouble reaching an agreement as to what has to actually be tested here:

    • From my very own perspective, only Section 1.3 of the standard is authoritative while the rest is merely background information (just as an indicator, the typical "must" and "should" are not to be found there); therefore I suggest that Section 1.3 be moved up a level (because I don't think it belongs under "Terminology").
    • Hannes, on the other hand, would argue that Section 1.3 is not sufficient, because it doesn't say anything about minimum kernel version, presence of haveged etc.

    @fkr @garloff @matfechner Can you tell us what parts of the document are actually authoritative, and do you agree that the sections should be restructured? Would you say that factors such as kernel version, haveged etc. should be mandated? I would be happy to provide a PR for any changes, of course.

  16. artificial-intelligence commented on May 23, 2023

    @artificial-intelligence

    Hi,

    From my very own perspective, only Section 1.3 of the standard is authoritative while the rest is merely background information (just as an indicator, the typical "must" and "should" are not to be found there);

    this is factually not correct, please read the standard, e.g. it says in section 1.2.3:

    For example haveged should not be use anymore[..]

    so that should also hopefully answer your question regarding haveged and also, by implication, the minimum kernel version.

    I agree, it could maybe worded more clearly.

    aside from that I'd urge everyone involved in this topic to read this very good, albeit old, article:

    https://www.2uo.de/myths-about-urandom/

    Additional wisdom might be found in jason a. donenfelds commits to the linux kernel and these articles detailing the topic, e.g. https://lwn.net/Articles/887207/

    you can find the overview for random numbers in the linux kernel here:

    https://lwn.net/Kernel/Index/#Random_numbers

    the most recent article would be https://lwn.net/Articles/884875/

  17. mbuechse commented on May 23, 2023

    @mbuechse

    @artificial-intelligence You're right, I missed a "should". I understand the statement in question as follows:

    If the running kernel is version 5.17 or higher, then haveged should not be used.

    In other words, a potential test could emit a warning if haveged is present on a system with kernel version 5.17 or higher. (I suppose a warning is enough because we are dealing with a "should" and not a "must"?) But is this really a requirement for SCS? I find the standard a bit unclear in this regard, and the original statement by @garloff says nothing of this kind:

    As an SCS IaaS user, [...] I configure virtio-rng guest driver in the VM and expect virtio-rng to be supported from the host (hypervisor).

    So, in my humble opinion, clarifications would be very beneficial.

    Besides, I'm puzzled by the list of articles that you mentioned in your comment. So far, the structure of the standard suggests that it is self-contained to a certain degree, so much so that it should be possible to be implemented without consulting further documents from the internet that aren't even mentioned in the standard. I think if the standard is unclear as to how it can be satisfied, then we definitely have to extend it.

  18. fkr commented on May 24, 2023

    @fkr
    Member

    We wanted to have a (quick?) call on this anyways (at least, we concluded this in last weeks IaaS call).
    Would next tuesday (May 30th) at 11:30 CEST or 14:00 CEST work? @cah-hbaum @mbuechse @matfechner @artificial-intelligence - just signal via 👍 or 👎

  19. matfechner commented on May 24, 2023

    @matfechner

    @fkr +1 both appointments are fine for me

  20. fkr commented on May 25, 2023

    @fkr
    Member

    Since @artificial-intelligence is not available during the times I proposed, a new proposal would be 1530 CEST on tuesday.
    I'll send out an invite.

  21. added
    Sprint Dublin
    on May 31, 2023
  22. garloff commented on Jun 7, 2023

    @garloff
    MemberAuthor

    Discussion 2023-06-07:
    Three topics:
    (1) Lowest common denominator - fortunately no longer an issue with modern hardware and linux kernels (5.18+, backported into vendor kernels, e.g. Ubu20.04's 5.4) IN GUEST

    • SCS requirement: Require x86-64 CPUs to support RDSEED/RDRANDOM (and not to be filtered out), likewise require equivalent stuff on ARM
    • Require operator managed images to be kept up to date (increasing chances those use RDSEED/RDRANDOM)
      (1a) Requirement for SCS mandatory images: SCS should validate that all of them use RDSEED ...

    (2) virtio-rng was the traditional way to get (reasonable?) entropy into VM

    • Should SCS require this to be there? (-> recommended)
    • Quality requirements for randomness/entropy?

    (3) virtio-rng Advanced HW-RNG

    • Needs to be used by HOST with rngd, then exposed via virtio-rng to VM
      (3a) This could become a flavor flag indicating that virtio-rng has especially high quality random numbers
      => This will become part of a future flavor standard, with requirements to the quality of the randomness
  23. mbuechse commented on Jun 8, 2023

    @mbuechse

    I updated the branch (see PR 297) accordingly (as far as I understood).

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

Metadata

Metadata

Assignees

Labels

IaaSSCS is standardizedSprint BratislavaSprint CopenhagenSprint Dublinstandards

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions