Skip to content

Revision of scs-0101-v1-entropy - #297

Merged
mbuechse merged 13 commits into
mainfrom
scs-0100-v1-entropy-revised
Jun 9, 2023
Merged

mbuechse merged 13 commits into
mainfrom
scs-0100-v1-entropy-revised

Conversation

@mbuechse

@mbuechse mbuechse commented Jun 2, 2023 •

Copy link
Copy Markdown
Contributor

Hi everyone.

I tried to apply the structure suggested by scs-0001. Besides, I did a kinda deep dive into the topic of entropy, and I revised the draft accordingly. Please have a look.

Most important insights to me:

  • linux does not treat RDRAND/RDSEED like a classical hardware rng (it doesn't appear as /dev/hwrng and it's automatically part of the entropy pool)
  • therefore rngd is only required on the host if it does feature a true hw rng
  • for the same reason (namely, that linux automatically uses RDRAND), it seems to me that it's mostly up to the user's taste whether they want to use virtio-rng

edit just mention SovereignCloudStack/issues#234 to make the connection

@mbuechse

mbuechse commented Jun 2, 2023

Copy link
Copy Markdown
Contributor Author

@mbuechse

mbuechse commented Jun 2, 2023

Copy link
Copy Markdown
Contributor Author

Now I'm wondering if the flavor name scheme should be extended to account for the presence of a true hw rng? Is this something that should be standardized?

@cah-hbaum cah-hbaum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a review, some text changes as well as one "bigger"ish discussion point came up for me.

Also (because we talked about) the following command provides the path to a possible
hardware device as a source for randomness in a VM. I don't know if we want to put this anyhwere, but there it is.
/sys/devices/virtual/misc/hw_random/rng_available

Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Outdated

This standard does not intend to make any guarantees for linux images
that are not themselves included in the
[SCS standard](https://github.com/SovereignCloudStack/standards/blob/main/Standards/scs-0102-v1-image-metadata.md), in particular

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[SCS standard](https://github.com/SovereignCloudStack/standards/blob/main/Standards/scs-0102-v1-image-metadata.md), in particular
[Image Metadata SCS standard](https://github.com/SovereignCloudStack/standards/blob/main/Standards/scs-0102-v1-image-metadata.md), in particular

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is indeed a bit tricky. I guess what I mean here is not the image metadata standard itself, but the certification level SCS compatible, which includes the image metadata standard. What the CSPs get certified for is the bundle as a whole. However, speaking of "SCS certification level SCS compatible" is a mouthful. Therefore I opted for SCS standard, but then only linked the relevant document.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working on SovereignCloudStack/issues#343, I learned that there is such a thing as "the SCS standard", namely with respect to a given release number, and it comprises all standards that are denoted as stable in that release. Source: https://github.com/SovereignCloudStack/standards/blob/main/Standards/scs-0001-v1-sovereign-cloud-standards.md#stabilized-phase-stable

So the wording "SCS standard" is not unprecedented and it is even well defined. The image metadata standard is stable, and I guess it will remain so for the upcoming release. Therefore it should be warranted to speak of the SCS standard at large while linking to a specific document that is part of the standard.

Comment thread Standards/scs-0101-v1-entropy.md Resolved
Comment thread Standards/scs-0101-v1-entropy.md Outdated
Comment on lines +118 to +120
Compute nodes must use CPUs that offer RDRAND/RDSEED. This requirement
is both very hard to verify and almost impossible to violate, so it will
not be tested for.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why must RDRAND/RDSEED be necessary? I couldn't find a hard requirement for them in the linux kernel or anywhere else (e.g. OpenSSL also only lists them as an optional tool to generate their keys and so on).
https://en.wikipedia.org/wiki/RDRAND and the connected sources state that it was a source for randomness in previous kernel version, but not the only one in the pool, and since the algorithm was changed in favor of using CPU jitter (which doesn't come from RDRAND/RDSEED), this requirement should not be necessary in my opinion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My interpretation of the Donenfeld writeup was that his algorithm uses the first instruction of the following list that is supported by the CPU: RDSEED, RDRAND, RDTSC. It suggested to me that RDSEED was somehow superior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it uses these Operations in this order, but it doesn't decrease the value of the entropy significantly if one of the later methods is used, since it is only mixed in as an entropy source, see

I touched on RDSEED usage earlier, and there are in fact some more detailed changes on that topic. In random: use RDSEED instead of RDRAND in entropy extraction, the RNG now uses RDSEED, if available, before falling back to RDRAND and eventually RDTSC. Since the CPU’s RNG is just another entropy input source — one we happen to call at boot time for initial seeding and during each subsequent reseeding — we might as well use its best source. We’re not using it as part of the direct generation of random numbers itself, but just as an additional entropy input, and hence there’s not a need for the speed improvements of RDRAND over RDSEED. (Incidentally I recently removed direct RDRAND-usage from systemd too.)

So I wouldn't write this in as a requirement, especially since most modern x86-CPUs would fullfill these requirements anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that mandating this is kind of redundant (because the instructions are present anyway, and because the kernel works fine without them).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to get more feedback in tomorrow's meeting, and if nobody intervenes, I will remove this requirement.

Comment thread Standards/scs-0101-v1-entropy.md Resolved
@mbuechse

mbuechse commented Jun 5, 2023

Copy link
Copy Markdown
Contributor Author

Can we get another review before the next team meeting on Wednesday? @matfechner @artificial-intelligence @garloff
No is a valid answer of course, I just want to bump this topic once.

@fkr fkr added IaaS Issues or pull requests relevant for Team1: IaaS SCS is standardized SCS is standardized Sprint Dublin Sprint Dublin (2023, cwk 22+23) labels Jun 6, 2023

@matfechner matfechner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mbuechse and others added 10 commits June 8, 2023 10:20
…t current state of the art

Signed-off-by: Matthias Büchse <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Co-authored-by: cah-hbaum <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
courtesy of @cah-hbaum

Co-authored-by: cah-hbaum <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Co-authored-by: cah-hbaum <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
@mbuechse
mbuechse force-pushed the scs-0100-v1-entropy-revised branch from 0f6623a to f7c71ea Compare June 8, 2023 08:20
@mbuechse

mbuechse commented Jun 8, 2023

Copy link
Copy Markdown
Contributor Author

Note: I did a rebase, so if you have a local copy, please do as follows:

git pull
git reset --hard origin/scs-0100-v1-entropy-revised

@mbuechse
mbuechse requested review from cah-hbaum and matfechner June 8, 2023 08:22
Signed-off-by: Matthias Büchse <[email protected]>
@mbuechse mbuechse removed the Sprint Dublin Sprint Dublin (2023, cwk 22+23) label Jun 8, 2023
Comment thread Standards/scs-0101-v1-entropy.md Outdated
Comment on lines +34 to +36
[HavegeD](http://www.issihosts.com/haveged/)) as well as the special CPU
instructions RDRAND and RDSEED, which are present in all modern CPUs from
ARM, AMD, and Intel.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARM (actually ARM64 to be precise) does not have RDRAND/RDSEED but has RNDR - if I'm not mistaken.
If we become that specific, we should make sure to not tie it too much into x86_64 language.

Comment thread Standards/scs-0101-v1-entropy.md Outdated
Comment on lines +120 to +121
Compute nodes must use CPUs that offer RDRAND/RDSEED, and these
instructions may not be filtered by the hypervisor. If this requirement

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will prevent CSPs from deploying ARM64 based compute nodes once we offer this functionality (which we will). Imho we should write this in a way that does not require us to revise it when we do that.

@fkr fkr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the note about RDRAND/RDSEED and it being very x86_64 specific (which did not occur to me earlier - sorry for that!) i really like this document.
Maybe we can formulate that a bit flexible and than I'd say this is good to go.

Thanks to @fkr for pointing this out!

Signed-off-by: Matthias Büchse <[email protected]>
@mbuechse

mbuechse commented Jun 9, 2023

Copy link
Copy Markdown
Contributor Author

@fkr Thank you for your kind words and helpful remarks! I tried to address them with this commit: 1d9f960

@fkr fkr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fkr fkr added this to the R5 (v6.0.0) milestone Jun 9, 2023
@fkr fkr added the Sprint Dublin Sprint Dublin (2023, cwk 22+23) label Jun 9, 2023
@mbuechse
mbuechse merged commit a898bcd into main Jun 9, 2023
@mbuechse
mbuechse deleted the scs-0100-v1-entropy-revised branch June 9, 2023 13:23
cah-hbaum added a commit that referenced this pull request Jun 13, 2023
* adapt to the new standard introduced in #297
* added specific exceptions
* small inline documentation
* added return codes and explanation
* better explained log messages

Signed-off-by: Hannes Baum <[email protected]>
cah-hbaum added a commit that referenced this pull request Jun 13, 2023
* adapt to the new standard introduced in #297
* added specific exceptions
* small inline documentation
* added return codes and explanation
* better explained log messages

Signed-off-by: Hannes Baum <[email protected]>
cah-hbaum added a commit that referenced this pull request Jun 20, 2023
* adapt to the new standard introduced in #297
* added specific exceptions
* small inline documentation
* added return codes and explanation
* better explained log messages

Signed-off-by: Hannes Baum <[email protected]>
mbuechse pushed a commit that referenced this pull request Jun 20, 2023
* adapt to the new standard introduced in #297
* added specific exceptions
* small inline documentation
* added return codes and explanation
* better explained log messages

Signed-off-by: Hannes Baum <[email protected]>
mbuechse added a commit that referenced this pull request Jun 28, 2023
* Entropy Testing (#268)

* add script to check available entropy on VMs and OpenStack
* additional requirements

Signed-off-by: Hannes Baum <[email protected]>

* Entropy Test Improvements (#268)

* improvements to appease Flake8
* sort script imports
* add command-line options

Signed-off-by: Matthias Büchse <[email protected]>

* Move flavor and image checks up front, because they don't depend on the VM

Signed-off-by: Matthias Büchse <[email protected]>

* Update Entropy Test due to Standard Change (#268)

* adapt to the new standard introduced in #297
* added specific exceptions
* small inline documentation
* added return codes and explanation
* better explained log messages

Signed-off-by: Hannes Baum <[email protected]>

* Update Entropy test with optional changes (#268)

* possibility to check multiple images
* lists from image metadata standard
* more exception checks
* improved return codes
* improved usage output

Signed-off-by: Hannes Baum <[email protected]>

* Add different package managers (#268)

* handling for multiple package managers

Signed-off-by: Hannes Baum <[email protected]>

* Reworked the entropy test

- removed coupling with image standard (images have to be named in the yaml file)
- simplified return codes and logging
- simplified openstack API calls (e.g., use built-in feature to delete floating IPs)
- pick suitable flavor for checking virtio-rng, otherwise check is pointless
- made code more concise, added comments at a few surprising spots

Signed-off-by: Matthias Büchse <[email protected]>

* appease flake8 by correcting mistake

Signed-off-by: Matthias Büchse <[email protected]>

* Fixed type of flavor attribute hw_rng:allowed (it's bool, not str)

Signed-off-by: Matthias Büchse <[email protected]>

* Improvements thanks to @cah-hbaum's review

Signed-off-by: Matthias Büchse <[email protected]>

* Add different package managers (#268)

* handling for multiple package managers

Signed-off-by: Hannes Baum <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>

* Improved comments following review by @artificial-intelligence

Signed-off-by: Matthias Büchse <[email protected]>

* Multiple small bug fixes to make it work on a conformant cloud...

Signed-off-by: Matthias Büchse <[email protected]>

---------

Signed-off-by: Hannes Baum <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Co-authored-by: Matthias Büchse <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IaaS Issues or pull requests relevant for Team1: IaaS SCS is standardized SCS is standardized Sprint Dublin Sprint Dublin (2023, cwk 22+23)

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants