From: Gleb Natapov <gleb@kernel.org>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Mathew John <mathewj@microsoft.com>,
Theodore Ts'o <tytso@mit.edu>,
David Hepkin <davidhep@microsoft.com>,
kvm list <kvm@vger.kernel.org>,
Niels Ferguson <niels@microsoft.com>,
Linux Virtualization <virtualization@lists.linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Jake Oshins <jakeo@microsoft.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Alok N Kataria <akataria@vmware.com>,
John Starks <John.Starks@microsoft.com>
Subject: Re: Standardizing an MSR or other hypercall to get an RNG seed?
Date: Fri, 19 Sep 2014 23:53:42 +0300 [thread overview]
Message-ID: <20140919205342.GO26540@minantech.com> (raw)
In-Reply-To: <CALCETrX=HFB01rg_iCNNfEd8mEoj20hK2K-bU6FbgOkWF7fO-A@mail.gmail.com>
On Fri, Sep 19, 2014 at 11:20:49AM -0700, Andy Lutomirski wrote:
> [cc: Alok Kataria at VMware]
>
> On Fri, Sep 19, 2014 at 11:12 AM, Gleb Natapov <gleb@kernel.org> wrote:
> > On Fri, Sep 19, 2014 at 11:02:38AM -0700, Andy Lutomirski wrote:
> >> On Fri, Sep 19, 2014 at 10:49 AM, Gleb Natapov <gleb@kernel.org> wrote:
> >> > On Fri, Sep 19, 2014 at 10:18:37AM -0700, H. Peter Anvin wrote:
> >> >> On 09/19/2014 10:15 AM, Gleb Natapov wrote:
> >> >> > On Fri, Sep 19, 2014 at 10:08:20AM -0700, H. Peter Anvin wrote:
> >> >> >> On 09/19/2014 09:53 AM, Gleb Natapov wrote:
> >> >> >>> On Fri, Sep 19, 2014 at 09:40:07AM -0700, H. Peter Anvin wrote:
> >> >> >>>> On 09/19/2014 09:37 AM, Gleb Natapov wrote:
> >> >> >>>>>
> >> >> >>>>> Linux detects what hypervior it runs on very early
> >> >> >>>>
> >> >> >>>> Not anywhere close to early enough. We're talking for uses like kASLR.
> >> >> >>>>
> >> >> >>> Still to early to do:
> >> >> >>>
> >> >> >>> h = cpuid(HYPERVIOR_SIGNATURE)
> >> >> >>> if (h == KVMKVMKVM) {
> >> >> >>> if (cpuid(kvm_features) & kvm_rnd)
> >> >> >>> rdmsr(kvm_rnd)
> >> >> >>> else (h == HyperV) {
> >> >> >>> if (cpuid(hv_features) & hv_rnd)
> >> >> >>> rdmsr(hv_rnd)
> >> >> >>> else (h == XenXenXen) {
> >> >> >>> if (cpuid(xen_features) & xen_rnd)
> >> >> >>> rdmsr(xen_rnd)
> >> >> >>> }
> >> >> >>>
> >> >> >>
> >> >> >> If we need to do chase loops, especially not so...
> >> >> >>
> >> >> > What loops exactly? As a non native English speaker I fail to understand
> >> >> > if your answer is "yes" or "no" ;)
> >> >> >
> >> >>
> >> >> The above isn't actually the full algorithm used.
> >> >>
> >> > What part of actually algorithm cannot be implemented? Loop that searches
> >> > for KVM leaf in case KVM pretend to be HyperV (is this what you called
> >> > "chase loops"?)? First of all there is no need to implement it, if KVM
> >> > pretends to be HyperV use HyperV's way to obtain RNG, but what is the
> >> > problem with the loop?
> >> >
> >>
> >> It can be implemented, and I've done it. But it's a mess. Almost the
> >> very first thing we do in boot (even before decompressing the kernel)
> >> will be to scan a bunch of cpuid leaves looking for a hypervisor with
> >> an rng source that we can use for kASLR. And we'll have to update
> >> that code and make it bigger every time another hypervisor adds
> >> exactly the same feature.
> > IMO implementing this feature is in hypervisor's best interest, so the task
> > of updating the code will scale by virtue of hypervisor's developers each
> > adding it for hypervisor he cares about.
>
> I assume that you mean guest, not hypervisor.
>
Yes, I mean guest support for hypervisor he cares about.
> >
> >>
> >> And then we have another copy of almost exactly the same code in the
> >> normal post-boot part of the kernel.
> >>
> >> We can certainly do this, but I'd much rather solve the problem once
> >> and let all of the hypervisors and guests opt in and immediately be
> >> compatible with each other.
> >>
> >> > I "forgot" VMware because I do not see VMware people to be CCed. They may
> >> > be even less excited about them being told _how_ this feature need to be
> >> > implemented (e.g implement HyperV leafs for the feature detection). I
> >> > do not want to and cannot speak for VMware, but my guess is that for
> >> > them it would be much easier to add an else clause for VMware in above
> >> > "if" then to coordinate with all hypervisor developers about MSR/cpuid
> >> > details. And since this is security feature implementing it for Linux
> >> > is in their best interest.
> >>
> >> Do you know any of them who should be cc'd?
> >>
> > No, not anyone in particular. git log arch/x86/kernel/cpu/vmware.c may help.
> >
> > But VMware is an elephant in the room here. There are other hypervisors out there.
> > VirtualBox, bhyve...
>
> Exactly. The amount of effort to get everything to be compatible with
> everything scales quadratically in the number of hypervisors, and the
> probability that some combination is broken also increases.
>
The effort is distributed equally among hypervisor developers. If they
want Linux to be more secure on their hypervisor they contribute guest
code. They do need to write hypervisor part anyway. On cpus with RDRAND
instruction this MSR is not even needed and some hypervisors may decide
that support for old cpus does not worth the effort. Unified interface
does not help if hypervisor does not implement it.
--
Gleb.
next prev parent reply other threads:[~2014-09-19 20:53 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 2:50 Standardizing an MSR or other hypercall to get an RNG seed? Andy Lutomirski
2014-09-18 14:40 ` KY Srinivasan
[not found] ` <2aa00301e9af4826b5781e01709f81e7@BY2PR0301MB0711.namprd03.prod.outlook.com>
2014-09-18 14:43 ` H. Peter Anvin
2014-09-18 15:38 ` Andy Lutomirski
2014-09-18 15:44 ` Andy Lutomirski
2014-09-18 15:58 ` Paolo Bonzini
2014-09-18 16:36 ` KY Srinivasan
[not found] ` <5b9c7dcde3824e49a25f3ee00844b868@BY2PR0301MB0711.namprd03.prod.outlook.com>
2014-09-18 17:13 ` Nakajima, Jun
2014-09-18 17:17 ` Paolo Bonzini
[not found] ` <541B13B8.1020006@redhat.com>
2014-09-18 17:20 ` Jake Oshins
2014-09-18 17:20 ` KY Srinivasan
[not found] ` <b697ef83ae594d8fb34347339dd52dfa@BY2PR0301MB0711.namprd03.prod.outlook.com>
2014-09-18 17:42 ` Nakajima, Jun
2014-09-18 18:35 ` Andy Lutomirski
2014-09-18 18:39 ` H. Peter Anvin
2014-09-18 18:54 ` Niels Ferguson
2014-09-18 19:03 ` Andy Lutomirski
2014-09-18 21:54 ` David Hepkin
[not found] ` <572ba53a2e1e4278823f718a421e2c1d@BY2PR03MB585.namprd03.prod.outlook.com>
2014-09-19 6:04 ` Paolo Bonzini
2014-09-18 18:58 ` Paolo Bonzini
2014-09-18 19:07 ` Andy Lutomirski
2014-09-18 21:21 ` Nakajima, Jun
2014-09-18 21:35 ` Andy Lutomirski
2014-09-18 21:46 ` David Hepkin
[not found] ` <0180a8dfcad746a895755c4374853c16@BY2PR03MB585.namprd03.prod.outlook.com>
2014-09-18 21:57 ` H. Peter Anvin
2014-09-18 22:07 ` Andy Lutomirski
2014-09-19 0:49 ` Nakajima, Jun
[not found] ` <CAL54oT1Q8kABge=t4s5REVWWakboON-6vfszMRkVz=ks_3vRoA@mail.gmail.com>
2014-09-19 1:03 ` Andy Lutomirski
2014-09-19 1:28 ` Andy Lutomirski
[not found] ` <CALCETrWZ1cF23aT82yGfTKS48d2G+_Od7hEkAzDWzDhqpHNVqA@mail.gmail.com>
2014-09-19 16:14 ` Nakajima, Jun
2014-09-19 16:22 ` Paolo Bonzini
2014-09-19 16:40 ` H. Peter Anvin
2014-09-19 17:21 ` Andy Lutomirski
2014-09-19 17:36 ` H. Peter Anvin
2014-09-19 17:39 ` Andy Lutomirski
2014-09-19 22:05 ` Theodore Ts'o
2014-09-19 22:06 ` Andy Lutomirski
2014-09-19 22:57 ` Nakajima, Jun
2014-09-19 22:57 ` Theodore Ts'o
2014-09-19 23:12 ` Andy Lutomirski
2014-09-19 23:29 ` H. Peter Anvin
2014-09-19 23:29 ` H. Peter Anvin
2014-09-19 23:35 ` Theodore Ts'o
2014-09-19 23:41 ` Andy Lutomirski
2014-09-20 0:06 ` H. Peter Anvin
2014-09-18 22:00 ` Andy Lutomirski
2014-09-18 22:03 ` H. Peter Anvin
2014-09-19 16:37 ` Gleb Natapov
2014-09-19 16:40 ` H. Peter Anvin
2014-09-19 16:53 ` Gleb Natapov
2014-09-19 17:08 ` H. Peter Anvin
2014-09-19 17:15 ` Gleb Natapov
2014-09-19 17:18 ` H. Peter Anvin
2014-09-19 17:49 ` Gleb Natapov
2014-09-19 18:02 ` Andy Lutomirski
2014-09-19 18:12 ` Gleb Natapov
2014-09-19 18:20 ` Andy Lutomirski
2014-09-19 20:53 ` Gleb Natapov [this message]
2014-09-22 4:11 ` Alok Kataria
2014-09-19 17:18 ` H. Peter Anvin
2014-09-19 17:21 ` Andy Lutomirski
2014-09-19 17:59 ` Gleb Natapov
2014-09-18 18:56 ` Paolo Bonzini
2014-09-19 18:30 ` Christopher Covington
2014-09-19 18:42 ` Andy Lutomirski
2014-09-19 20:21 ` Nadav Amit
[not found] ` <15C8041A-3488-4693-B329-3A9FE77A0CB9@gmail.com>
2014-09-19 20:46 ` Andy Lutomirski
2014-09-19 21:46 ` H. Peter Anvin
2014-09-22 13:31 ` Christopher Covington
2014-09-22 14:17 ` H. Peter Anvin
2014-09-22 14:18 ` H. Peter Anvin
2014-09-22 23:01 ` H. Peter Anvin
2014-09-21 12:39 ` Paolo Bonzini
2014-09-22 13:33 ` Christopher Covington
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=20140919205342.GO26540@minantech.com \
--to=gleb@kernel.org \
--cc=John.Starks@microsoft.com \
--cc=akataria@vmware.com \
--cc=davidhep@microsoft.com \
--cc=hpa@zytor.com \
--cc=jakeo@microsoft.com \
--cc=kvm@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mathewj@microsoft.com \
--cc=niels@microsoft.com \
--cc=pbonzini@redhat.com \
--cc=tytso@mit.edu \
--cc=virtualization@lists.linux-foundation.org \
/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).