Linux-arch Archive mirror
 help / color / mirror / Atom feed
From: Michael Kelley <mhklinux@outlook.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: "haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"decui@microsoft.com" <decui@microsoft.com>,
	"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
	"will@kernel.org" <will@kernel.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>, "arnd@arndb.de" <arnd@arndb.de>,
	"tytso@mit.edu" <tytso@mit.edu>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>
Subject: RE: [PATCH v3 1/1] x86/hyperv: Use Hyper-V entropy to seed guest random number generator
Date: Mon, 18 Mar 2024 22:49:58 +0000	[thread overview]
Message-ID: <SN6PR02MB4157453833547D915BF3F326D42D2@SN6PR02MB4157.namprd02.prod.outlook.com> (raw)
In-Reply-To: <ZfisGSPX9et2hGzx@zx2c4.com>

From: Jason A. Donenfeld <Jason@zx2c4.com> Sent: Monday, March 18, 2024 2:03 PM
> 
> On Mon, Mar 18, 2024 at 08:54:08AM -0700, mhkelley58@gmail.com wrote:
> > From: Michael Kelley <mhklinux@outlook.com>
> >
> > A Hyper-V host provides its guest VMs with entropy in a custom ACPI
> > table named "OEM0".  The entropy bits are updated each time Hyper-V
> > boots the VM, and are suitable for seeding the Linux guest random
> > number generator (rng). See a brief description of OEM0 in [1].
> >
> > Generation 2 VMs on Hyper-V use UEFI to boot. Existing EFI code in
> > Linux seeds the rng with entropy bits from the EFI_RNG_PROTOCOL.
> > Via this path, the rng is seeded very early during boot with good
> > entropy. The ACPI OEM0 table provided in such VMs is an additional
> > source of entropy.
> >
> > Generation 1 VMs on Hyper-V boot from BIOS. For these VMs, Linux
> > doesn't currently get any entropy from the Hyper-V host. While this
> > is not fundamentally broken because Linux can generate its own entropy,
> > using the Hyper-V host provided entropy would get the rng off to a
> > better start and would do so earlier in the boot process.
> >
> > Improve the rng seeding for Generation 1 VMs by having Hyper-V specific
> > code in Linux take advantage of the OEM0 table to seed the rng. For
> > Generation 2 VMs, use the OEM0 table to provide additional entropy
> > beyond the EFI_RNG_PROTOCOL. Because the OEM0 table is custom to
> > Hyper-V, parse it directly in the Hyper-V code in the Linux kernel
> > and use add_bootloader_randomness() to add it to the rng. Once the
> > entropy bits are read from OEM0, zero them out in the table so
> > they don't appear in /sys/firmware/acpi/tables/OEM0 in the running
> > VM. The zero'ing is done out of an abundance of caution to avoid
> > potential security risks to the rng. Also set the OEM0 data length
> > to zero so a kexec or other subsequent use of the table won't try
> > to use the zero'ed bits.
> >
> > [1] https://download.microsoft.com/download/1/c/9/1c9813b8-089c-4fef-b2ad-ad80e79403ba/Whitepaper%20-%20The%20Windows%2010%20random%20number%20generation%20infrastructure.pdf 
> 
> Looks good to me. Assuming you've tested this and it works,

Yes, tested on both x86 and arm64.  Thanks.

Michael

> 
>  Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
> 
> Thanks for the v3.
> 
> Jason

  reply	other threads:[~2024-03-18 22:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 15:54 [PATCH v3 1/1] x86/hyperv: Use Hyper-V entropy to seed guest random number generator mhkelley58
2024-03-18 17:21 ` Nuno Das Neves
2024-03-18 21:03 ` Jason A. Donenfeld
2024-03-18 22:49   ` Michael Kelley [this message]
2024-03-18 22:04 ` Wei Liu

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=SN6PR02MB4157453833547D915BF3F326D42D2@SN6PR02MB4157.namprd02.prod.outlook.com \
    --to=mhklinux@outlook.com \
    --cc=Jason@zx2c4.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tytso@mit.edu \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).