Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

vc: qemu: Add config option to choose entropy source. #781

Merged
merged 1 commit into from
Sep 26, 2018

Conversation

jcvenegas
Copy link
Member

@jcvenegas jcvenegas commented Sep 24, 2018

Today we use /dev/random as entropy source.
This is a blocking entropy source, when the
host is getting a low amount of entropy the
Kata VM startup takes longer because block
trying to get entropy from the source.

This change allow to change the entropy source.
For example: urandom
Fixes: #702

@jcvenegas
Copy link
Member Author

/test

@katacontainersbot
Copy link
Contributor

PSS Measurement:
Qemu: 169896 KB
Proxy: 4164 KB
Shim: 8984 KB

Memory inside container:
Total Memory: 2043448 KB
Free Memory: 2006588 KB

@@ -525,7 +525,8 @@ func (q *qemuArchBase) appendVFIODevice(devices []govmmQemu.Device, vfioDev conf
func (q *qemuArchBase) appendRNGDevice(devices []govmmQemu.Device, rngDev config.RNGDev) []govmmQemu.Device {
devices = append(devices,
govmmQemu.RngDevice{
ID: rngDev.ID,
ID: rngDev.ID,
Filename: "/dev/urandom",
Copy link

Choose a reason for hiding this comment

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

@jcvenegas looks good, but don't you think we should make this configurable instead of hardcoding in govmm ?
We should have the opportunity to select /dev/urandom from Kata code, WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, updating.

@codecov
Copy link

codecov bot commented Sep 24, 2018

Codecov Report

Merging #781 into master will decrease coverage by <.01%.
The diff coverage is 50%.

@@            Coverage Diff             @@
##           master     #781      +/-   ##
==========================================
- Coverage   65.32%   65.32%   -0.01%     
==========================================
  Files          87       87              
  Lines       10611    10619       +8     
==========================================
+ Hits         6932     6937       +5     
- Misses       2982     2985       +3     
  Partials      697      697

@jcvenegas jcvenegas force-pushed the urandom-source branch 2 times, most recently from 6e7cb17 to 3380bf2 Compare September 25, 2018 00:01
@laijs
Copy link
Contributor

laijs commented Sep 25, 2018

this change makes me a little nervous. security is important in this project. I would prefer /dev/random as the DEFAULT source.

@WeiZhang555
Copy link
Member

The code looks good, but I have a question. Do we need a configuration option? I mean, in which situation should we choose /dev/random against /dev/urandom ? Will be /dev/urandom always a prefered option?

@sboeuf
Copy link

sboeuf commented Sep 25, 2018

/test

@sboeuf
Copy link

sboeuf commented Sep 25, 2018

@laijs @WeiZhang555 I have asked the question about /dev/urandom on the kata-dev mailing list. Please give more details about the potential issue related to using /dev/urandom

@katacontainersbot
Copy link
Contributor

PSS Measurement:
Qemu: 165442 KB
Proxy: 4153 KB
Shim: 8792 KB

Memory inside container:
Total Memory: 2043448 KB
Free Memory: 2006580 KB

@bergwolf bergwolf mentioned this pull request Sep 25, 2018
@jodh-intel
Copy link
Contributor

Would it be worth atleast logging the value of /proc/sys/kernel/random/entropy_avail on container create as a debug aid?

I suspect we can't reliably determine how much entropy we'd actually need. But if we could, if the system entropy falls below that threshold, we could make that a hard error.

@@ -319,6 +320,7 @@ func getHypervisorInfo(config oci.RuntimeConfig) HypervisorInfo {
Msize9p: config.HypervisorConfig.Msize9p,
UseVSock: config.HypervisorConfig.UseVSock,
MemorySlots: config.HypervisorConfig.MemSlots,
EntropySource: config.HypervisorConfig.EntropySource,
Copy link
Contributor

Choose a reason for hiding this comment

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

/cc @markdryan

Copy link
Member Author

Choose a reason for hiding this comment

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

@jodh-intel qemu complains about it, OCI runtime create failed: qemu-system-x86_64: -object rng-random,id=rng0,filename=/tmp/r: Could not open '/tmp/r': No such file or directory: unknown

@jcvenegas
Copy link
Member Author

/retest

@katacontainersbot
Copy link
Contributor

PSS Measurement:
Qemu: 169678 KB
Proxy: 3994 KB
Shim: 8882 KB

Memory inside container:
Total Memory: 2043448 KB
Free Memory: 2006448 KB

@jcvenegas jcvenegas changed the title vc: qemu: Use urandom as entropy source. vc: qemu: Add config option to choose entropy source. Sep 25, 2018
@jcvenegas jcvenegas force-pushed the urandom-source branch 3 times, most recently from fcc028b to fb6fc8a Compare September 25, 2018 21:13
@sboeuf
Copy link

sboeuf commented Sep 25, 2018

/retest

Copy link

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

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

Based on the several inputs we got on the kata-dev mailing list, it is fine to pursue with this approach and I am all for merging this :)

Makefile Outdated
@@ -136,6 +136,8 @@ DEFMEMSLOTS := 10
DEFBRIDGES := 1
#Default network model
DEFNETWORKMODEL := macvtap
#Default entropy source
DEFENTROPYSOURCE := /dev/random
Copy link
Member

Choose a reason for hiding this comment

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

should the default be /dev/urandom?

Makefile Outdated
@@ -136,6 +136,8 @@ DEFMEMSLOTS := 10
DEFBRIDGES := 1
#Default network model
DEFNETWORKMODEL := macvtap
#Default entropy source
DEFENTROPYSOURCE := /dev/random
Copy link

Choose a reason for hiding this comment

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

Oh sorry, I'd like urandom to be the default here, and we should add some comments related to /dev/random, explaining this can be used but with some limitations.

@katacontainersbot
Copy link
Contributor

PSS Measurement:
Qemu: 169098 KB
Proxy: 4253 KB
Shim: 8722 KB

Memory inside container:
Total Memory: 2043448 KB
Free Memory: 2006332 KB

This adds a config option to choose the VM entropy
source.

Fixes: kata-containers#702

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
@jcvenegas
Copy link
Member Author

/test

@katacontainersbot
Copy link
Contributor

PSS Measurement:
Qemu: 171426 KB
Proxy: 4073 KB
Shim: 8834 KB

Memory inside container:
Total Memory: 2043448 KB
Free Memory: 2006712 KB

@bergwolf
Copy link
Member

Per Ted's recommendation on the mailing list, we are proceeding the patch with just seeding virtio-rng with /dev/urandom[1]. Let's remove the wip label and merge it since it has already got enough ACKs.

[1] http://lists.katacontainers.io/pipermail/kata-dev/2018-September/000439.html

@bergwolf bergwolf merged commit 304ec7e into kata-containers:master Sep 26, 2018
@jcvenegas jcvenegas deleted the urandom-source branch January 18, 2019 17:16
@jcvenegas jcvenegas restored the urandom-source branch September 30, 2019 18:48
@jcvenegas jcvenegas deleted the urandom-source branch January 23, 2020 19:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants