Easier Access to Random Numbers in KVM VMs

I’ve written previously about random numbers in virtual machines.  KVM still remains the only hypervisor to offer an RNG device to guests.

Quite a lot of exciting changes have landed in the upstream Linux kernel since that last post.  I have written an article in the RHEL blog about it: Red Hat Enterprise Linux Virtual Machines: Access to Random Numbers Made Easy.

That articles talks about the improvements in the recent RHEL 7.1 release.  In upstream terms, all the changes written about have landed in kernel 3.17; so Fedora 21 out-of-the-box, and Fedora 20 after updates, have benefited from the additions.

All the benefits listed in the article apply to all Linux guest VMs running under KVM if they have the virtio-rng device enabled, and run kernel 3.17+ in the guest.

About Random Numbers and Virtual Machines

Several applications need random numbers for correct and secure operation.  When ssh-server gets installed on a system, public and private key paris are generated.  Random numbers are needed for this operation.  Same with creating a GPG key pair.  Initial TCP sequence numbers are randomized.  Process PIDs are randomized.  Without such randomization, we’d get a predictable set of TCP sequence numbers or PIDs, making it easy for attackers to break into servers or desktops.


On a system without any special hardware, Linux seeds its entropy pool from sources like keyboard and mouse input, disk IO, network IO, and any other sources whose kernel modules indicate they are capable of adding to the kernel’s entropy pool (i.e .the interrupts they receive are from sufficiently non-deterministic sources).  For servers, keyboard and mouse inputs are rare (most don’t even have a keyboard / mouse connected).  This makes getting true random numbers difficult: applications requesting random numbers from /dev/random have to wait for indefinite periods to get the randomness they desire (like creating ssh keys, typically during firstboot.).


Continue reading About Random Numbers and Virtual Machines