[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXGbP+NGjqLndPS7EO_sazyoN7ot5siCR5hPTJfNYU2SaQ@mail.gmail.com>
Date: Fri, 25 Feb 2022 16:03:15 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: Alexander Graf <graf@...zon.com>
Cc: "Jason A. Donenfeld" <Jason@...c4.com>,
KVM list <kvm@...r.kernel.org>,
Linux Crypto Mailing List <linux-crypto@...r.kernel.org>,
linux-hyperv@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
adrian@...ity.io, ben@...portsystems.com,
Daniel P. Berrangé <berrange@...hat.com>,
Colm MacCarthaigh <colmmacc@...zon.com>,
Dexuan Cui <decui@...rosoft.com>,
"Woodhouse, David" <dwmw@...zon.co.uk>,
Eric Biggers <ebiggers@...nel.org>,
Eduardo Habkost <ehabkost@...hat.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Igor Mammedov <imammedo@...hat.com>,
Jann Horn <jannh@...gle.com>,
KY Srinivasan <kys@...rosoft.com>,
Laszlo Ersek <lersek@...hat.com>,
Dominik Brodowski <linux@...inikbrodowski.net>,
"Michael S. Tsirkin" <mst@...hat.com>,
QEMU Developers <qemu-devel@...gnu.org>,
"Weiss, Radu" <raduweis@...zon.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
"Theodore Y. Ts'o" <tytso@....edu>, Wei Liu <wei.liu@...nel.org>
Subject: Re: [PATCH v4] virt: vmgenid: introduce driver for reinitializing RNG
on VM fork
On Fri, 25 Feb 2022 at 14:58, Alexander Graf <graf@...zon.com> wrote:
>
>
> On 25.02.22 13:48, Jason A. Donenfeld wrote:
> >
> > VM Generation ID is a feature from Microsoft, described at
> > <https://go.microsoft.com/fwlink/?LinkId=260709>, and supported by
> > Hyper-V and QEMU. Its usage is described in Microsoft's RNG whitepaper,
> > <https://aka.ms/win10rng>, as:
> >
> > If the OS is running in a VM, there is a problem that most
> > hypervisors can snapshot the state of the machine and later rewind
> > the VM state to the saved state. This results in the machine running
> > a second time with the exact same RNG state, which leads to serious
> > security problems. To reduce the window of vulnerability, Windows
> > 10 on a Hyper-V VM will detect when the VM state is reset, retrieve
> > a unique (not random) value from the hypervisor, and reseed the root
> > RNG with that unique value. This does not eliminate the
> > vulnerability, but it greatly reduces the time during which the RNG
> > system will produce the same outputs as it did during a previous
> > instantiation of the same VM state.
> >
> > Linux has the same issue, and given that vmgenid is supported already by
> > multiple hypervisors, we can implement more or less the same solution.
> > So this commit wires up the vmgenid ACPI notification to the RNG's newly
> > added add_vmfork_randomness() function.
> >
> > It can be used from qemu via the `-device vmgenid,guid=auto` parameter.
> > After setting that, use `savevm` in the monitor to save the VM state,
> > then quit QEMU, start it again, and use `loadvm`. That will trigger this
> > driver's notify function, which hands the new UUID to the RNG. This is
> > described in <https://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/vmgenid.txt>.
> > And there are hooks for this in libvirt as well, described in
> > <https://libvirt.org/formatdomain.html#general-metadata>.
> >
> > Note, however, that the treatment of this as a UUID is considered to be
> > an accidental QEMU nuance, per
> > <https://github.com/libguestfs/virt-v2v/blob/master/docs/vm-generation-id-across-hypervisors.txt>,
> > so this driver simply treats these bytes as an opaque 128-bit binary
> > blob, as per the spec. This doesn't really make a difference anyway,
> > considering that's how it ends up when handed to the RNG in the end.
> >
> > Cc: Adrian Catangiu <adrian@...ity.io>
> > Cc: Daniel P. Berrangé <berrange@...hat.com>
> > Cc: Dominik Brodowski <linux@...inikbrodowski.net>
> > Cc: Ard Biesheuvel <ardb@...nel.org>
> > Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> > Reviewed-by: Laszlo Ersek <lersek@...hat.com>
> > Signed-off-by: Jason A. Donenfeld <Jason@...c4.com>
> > ---
...
> > +
> > + device->driver_data = state;
> > +
> > +out:
> > + ACPI_FREE(parsed.pointer);
> > + return ret;
> > +}
> > +
> > +static void vmgenid_acpi_notify(struct acpi_device *device, u32 event)
> > +{
> > + struct vmgenid_state *state = acpi_driver_data(device);
> > + u8 old_id[VMGENID_SIZE];
> > +
> > + memcpy(old_id, state->this_id, sizeof(old_id));
> > + memcpy(state->this_id, state->next_id, sizeof(state->this_id));
> > + if (!memcmp(old_id, state->this_id, sizeof(old_id)))
> > + return;
> > + add_vmfork_randomness(state->this_id, sizeof(state->this_id));
> > +}
> > +
> > +static const struct acpi_device_id vmgenid_ids[] = {
> > + { "VMGENID", 0 },
> > + { "QEMUVGID", 0 },
>
>
> According to the VMGenID spec[1], you can only rely on _CID and _DDN for
> matching. They both contain "VM_Gen_Counter". The list above contains
> _HID values which are not an official identifier for the VMGenID device.
>
> IIRC the ACPI device match logic does match _CID in addition to _HID.
> However, it is limited to 8 characters. Let me paste an experimental
> hack I did back then to do the _CID matching instead.
>
> [1]
> https://download.microsoft.com/download/3/1/C/31CFC307-98CA-4CA5-914C-D9772691E214/VirtualMachineGenerationID.docx
>
I think matching on the HIDs of two known existing implementations is
fine, as opposed to matching on the (broken) CID of any implementation
that claims to be compatible with it. And dumping random strings into
the _CID property doesn't mesh well with the ACPI spec either, which
is why we don't currently support it.
We could still check _DDN if we wanted to, but I don't think this is
necessary. Other implementations that want to target his driver
explicitly can always put VMGENID or QEMUVGID into the _CID.
Powered by blists - more mailing lists