kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: linux-kernel@vger.kernel.org, tytso@mit.edu, kvm@vger.kernel.org
Cc: security@kernel.org
Subject: repeatable boot randomness inside KVM guest
Date: Sat, 14 Apr 2018 22:59:21 +0300	[thread overview]
Message-ID: <20180414195921.GA10437@avx2> (raw)

SLAB allocators got CONFIG_SLAB_FREELIST_RANDOM option which randomizes
allocation pattern inside a slab:


	#ifdef CONFIG_SLAB_FREELIST_RANDOM
	/* Pre-initialize the random sequence cache */
	static int init_cache_random_seq(struct kmem_cache *s)
	{
		...

Then I printed actual random sequences for each kmem cache.
Turned out they were all the same for most of the caches and
they didn't vary across guest reboots.

	int cache_random_seq_create(struct kmem_cache *cachep, unsigned int count, gfp_t gfp)
	{
		...
		/* Get best entropy at this stage of boot */
	        prandom_seed_state(&state, get_random_long());

Then I searched internet and turned out KVM can pass randomness via
virtio-rng or something. So I linked /dev/urandom.

And it didn't help!

The only way to get randomness for SLAB is to enable RDRAND inside guest.

Is it KVM bug?

For the record I'm using qemu 2.11.1-r2 and whatever F27 ships now.

             reply	other threads:[~2018-04-14 19:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-14 19:59 Alexey Dobriyan [this message]
2018-04-14 22:41 ` repeatable boot randomness inside KVM guest Andy Lutomirski
2018-04-14 23:09   ` Alexey Dobriyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180414195921.GA10437@avx2 \
    --to=adobriyan@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=security@kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).