linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	KVM list <kvm@vger.kernel.org>,
	linux-s390@vger.kernel.org, adrian@parity.io, "Woodhouse,
	David" <dwmw@amazon.co.uk>,
	"Catangiu, Adrian Costin" <acatan@amazon.com>,
	graf@amazon.com, Colm MacCarthaigh <colmmacc@amazon.com>,
	"Singh, Balbir" <sblbir@amazon.com>,
	"Weiss, Radu" <raduweis@amazon.com>, Jann Horn <jannh@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Theodore Ts'o" <tytso@mit.edu>
Subject: Re: [PATCH RFC v1 1/2] random: add mechanism for VM forks to reinitialize crng
Date: Thu, 24 Feb 2022 12:15:32 +0100	[thread overview]
Message-ID: <CAHmME9rUD5QrgQMpoOCjv3crWFwn+BXXx9Dm0e2Kv4cJCYS+AQ@mail.gmail.com> (raw)
In-Reply-To: <YhbfDQ2ernjrRNRX@sol.localdomain>

Hey Eric,

On Thu, Feb 24, 2022 at 2:27 AM Eric Biggers <ebiggers@kernel.org> wrote:
>
> On Thu, Feb 24, 2022 at 01:54:54AM +0100, Jason A. Donenfeld wrote:
> > On 2/24/22, Eric Biggers <ebiggers@kernel.org> wrote:
> > > I think we should be removing cases where the base_crng key is changed
> > > directly
> > > besides extraction from the input_pool, not adding new ones.  Why not
> > > implement
> > > this as add_device_randomness() followed by crng_reseed(force=true), where
> > > the
> > > 'force' argument forces a reseed to occur even if the entropy_count is too
> > > low?
> >
> > Because that induces a "premature next" condition which can let that
> > entropy, potentially newly acquired by a storm of IRQs at power-on, be
> > bruteforced by unprivileged userspace. I actually had it exactly the
> > way you describe at first, but decided that this here is the lesser of
> > evils and doesn't really complicate things the way an intentional
> > premature next would. The only thing we care about here is branching
> > the crng stream, and so this does explicitly that, without having to
> > interfere with how we collect entropy. Of course we *also* add it as
> > non-credited "device randomness" so that it's part of the next
> > reseeding, whenever that might occur.
>
> Can you make sure to properly explain this in the code?

The carousel keeps turning, and after I wrote to you last night I kept
thinking about the matter. Here's how it breaks down:

Injection method:
- Assumes existing pool of entropy is still sacred.
- Assumes base_crng timestamp is representative of pool age.
- Result: Mixes directly into base_crng to avoid premature-next of pool.

Input pool method:
- Assumes existing pool of entropy is old / out of date / used by a
different fork, so not sacred.
- Assumes base_crng timestamp is tied to irrelevant entropy pool.
- Result: Force-drains input pool, causing intentional premature-next.

Which of these assumptions better models the situation? I started in
the input pool method camp, then by the time I posted v1, was
concerned about power-on IRQs, but now I think relying at all on
snapshotted entropy represents the biggest issue. And judging from
your email, it appears that you do too. So v3 of this patchset will
switch back to the input pool method, per your suggestion.

As a plus, it means we go through the RDSEED'd extraction algorithm
too, which always helps.

Jason

  reply	other threads:[~2022-02-24 11:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 13:12 [PATCH RFC v1 0/2] VM fork detection for RNG Jason A. Donenfeld
2022-02-23 13:12 ` [PATCH RFC v1 1/2] random: add mechanism for VM forks to reinitialize crng Jason A. Donenfeld
2022-02-23 23:16   ` Eric Biggers
2022-02-24  0:54     ` Jason A. Donenfeld
2022-02-24  1:27       ` Eric Biggers
2022-02-24 11:15         ` Jason A. Donenfeld [this message]
2022-02-23 13:12 ` [PATCH RFC v1 2/2] drivers/virt: add vmgenid driver for reinitializing RNG Jason A. Donenfeld
2022-02-23 16:36   ` Jason A. Donenfeld
2022-02-23 16:08 ` [PATCH RFC v1 0/2] VM fork detection for RNG Jason A. Donenfeld
2022-02-23 16:19   ` Jason A. Donenfeld
     [not found]   ` <2653b6c7-a851-7a48-f1f8-3bde742a0c9f@redhat.com>
2022-02-24 10:43     ` Jason A. Donenfeld
2022-02-24 10:55     ` Daniel P. Berrangé
2022-02-24 10:57       ` Jason A. Donenfeld
2022-02-25 10:40         ` Michael S. Tsirkin
2022-02-24  8:53 ` Alexander Graf
2022-02-24 10:43   ` Daniel P. Berrangé
2022-02-24 11:35     ` Alexander Graf
2022-02-24 10:53   ` Jason A. Donenfeld

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=CAHmME9rUD5QrgQMpoOCjv3crWFwn+BXXx9Dm0e2Kv4cJCYS+AQ@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=acatan@amazon.com \
    --cc=adrian@parity.io \
    --cc=colmmacc@amazon.com \
    --cc=dwmw@amazon.co.uk \
    --cc=ebiggers@kernel.org \
    --cc=graf@amazon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raduweis@amazon.com \
    --cc=sblbir@amazon.com \
    --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).