From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
"Jian J Wang" <jian.j.wang@intel.com>,
edk2-devel-groups-io <devel@edk2.groups.io>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Bret Barkelew" <Bret.Barkelew@microsoft.com>,
"qemu devel list" <qemu-devel@nongnu.org>,
"Erik Bjorge" <erik.c.bjorge@intel.com>,
"Sean Brogan" <sean.brogan@microsoft.com>,
"Laszlo Ersek" <lersek@redhat.com>
Subject: Re: privileged entropy sources in QEMU/KVM guests
Date: Thu, 7 Nov 2019 11:55:11 +0000 [thread overview]
Message-ID: <20191107115511.GE120292@redhat.com> (raw)
In-Reply-To: <ef126cd5-7b64-1b8a-ca74-11bd06b5f4b1@redhat.com>
On Thu, Nov 07, 2019 at 12:37:11PM +0100, Paolo Bonzini wrote:
> On 07/11/19 11:25, Ard Biesheuvel wrote:
> >> This looks problematic on QEMU. Entropy is a valuable resource, and
> >> whatever resource SMM drivers depend on, should not be possible for e.g.
> >> a 3rd party UEFI driver (or even for the runtime OS) to exhaust.
> >> Therefore, it's not *only* the case that SMM drivers must not consume
> >> EFI_RNG_PROTOCOL (which exists at a less critical privilege level, i.e.
> >> outside of SMM/SMRAM), but also that SMM drivers must not depend on the
> >> same piece of *hardware* that feeds EFI_RNG_PROTOCOL.
> >>
> > The typical model is to seed a DRBG [deterministic pseudorandom
> > sequence generator] using a sufficient amount of high quality entropy.
> > Once you have done that, it is rather hard to exhaust a DRBG - it is a
> > mathematical construction that is designed to last for a long time (<=
> > 2^48 invocations [not bytes] according to the NIST spec), after which
> > it does not degrade although it may have generated so much output that
> > its internal state may be inferred if you have captured enough of it
> > (which is a rather theoretical issue IMHO)
> >
> > The problem is that using the output of a DRBG as a seed is
> > non-trivial - the spec describes ways to do this, but wiring
> > virtio-rng to a DRBG in the host and using its output to seed a DRBG
> > in the guest is slighly problematic.
> >
> > So it seems to me that the correct way to model this is to make the
> > host's true entropy source a shared resource like any other.
> >
>
> Yes, I would make SMM use a cryptographic pseudo-random number generator
> and seed it from virtio-rng from DXE, way before the OS starts and can
> "attack" it.
>
> Once you've gotten a seed, you can create a CSPRNG with a stream cipher
> such as ChaCha20, which is literally 30 lines of code.
If all we need is a one-time seed then virtio-rng is possibly overkill as
that provides a continuous stream. Instead could QEMU read a few bytes
from the host's /dev/urandom and pass it to EDK via fw_cfg, which can
use it for the CSPRNG seed. EDK would have to erase the fw_cfg field
to prevent the seed value leaking to the guest OS, but other than that
its quite straightforward.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2019-11-07 11:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 10:10 privileged entropy sources in QEMU/KVM guests Laszlo Ersek
2019-11-07 10:18 ` Dr. David Alan Gilbert
2019-11-07 11:19 ` Laszlo Ersek
2019-11-07 11:36 ` Dr. David Alan Gilbert
2019-11-07 10:25 ` Ard Biesheuvel
2019-11-07 11:37 ` Paolo Bonzini
2019-11-07 11:55 ` Daniel P. Berrangé [this message]
2019-11-07 12:50 ` Paolo Bonzini
2019-11-07 13:33 ` Laszlo Ersek
2019-11-07 13:27 ` Laszlo Ersek
2019-11-07 13:58 ` Paolo Bonzini
2019-11-07 15:11 ` Laszlo Ersek
2019-11-07 11:58 ` Laszlo Ersek
2019-11-07 11:52 ` Daniel P. Berrangé
2019-11-07 12:47 ` Paolo Bonzini
2019-11-07 13:44 ` Laszlo Ersek
2019-11-07 13:54 ` Daniel P. Berrangé
2019-11-07 14:09 ` Ard Biesheuvel
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=20191107115511.GE120292@redhat.com \
--to=berrange@redhat.com \
--cc=Bret.Barkelew@microsoft.com \
--cc=ard.biesheuvel@linaro.org \
--cc=devel@edk2.groups.io \
--cc=erik.c.bjorge@intel.com \
--cc=jian.j.wang@intel.com \
--cc=lersek@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sean.brogan@microsoft.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.