linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@dominikbrodowski.net>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Theodore Ts'o <tytso@mit.edu>, "Ivan T. Ivanov" <iivanov@suse.de>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-efi@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	hsinyi@chromium.org
Subject: Re: [PATCH v4] random: fix crash on multiple early calls to add_bootloader_randomness()
Date: Fri, 3 Dec 2021 18:01:43 +0100	[thread overview]
Message-ID: <YapNd0byhBcnABei@light.dominikbrodowski.net> (raw)
In-Reply-To: <b2a5b4a7-4aee-558c-5558-549fd2998165@zx2c4.com>

Hi Jason,

Am Fri, Dec 03, 2021 at 05:47:41PM +0100 schrieb Jason A. Donenfeld:
> On 12/3/21 16:39, Jason A. Donenfeld wrote:
> > Hi Dominik,
> > 
> > Thanks for your analysis. Some more questions:
> > 
> > On Fri, Dec 3, 2021 at 8:59 AM Dominik Brodowski
> > <linux@dominikbrodowski.net> wrote:
> > > On subsequent calls to add_bootloader_randomness() and then to
> > > add_hwgenerator_randomness(), crng_fast_load() will be skipped. Instead,
> > > wait_event_interruptible() (which makes no sense for the init process)
> > > and then credit_entropy_bits() will be called. If the entropy count for
> > > that second seed is large enough, that proceeds to crng_reseed().
> > > However, crng_reseed() may depend on workqueues being available, which
> > > is not the case early during boot.
> > 
> > It sounds like *the* issue you've identified is that crng_reseed()
> > calls into workqueue functions too early in init, right? The bug is
> > about paths into crng_reseed() that might cause that?
> > 
> > If so, then specifically, are you referring to crng_reseed()'s call to
> > numa_crng_init()? In other words, the cause of the bug would be
> > 6c1e851c4edc ("random: fix possible sleeping allocation from irq
> > context")? If that's the case, then I wonder if the problem you're
> > seeing goes away if you revert both 6c1e851c4edc ("random: fix
> > possible sleeping allocation from irq context") and its primary
> > predecessor, 8ef35c866f88 ("random: set up the NUMA crng instances
> > after the CRNG is fully initialized"). These fix an actual bug, so I'm
> > not suggesting we actually revert these in the tree, but for the
> > purpose of testing, I'm wondering if this is actually the root cause
> > of the bug you're seeing.
> 
> If the above holds, I wonder if something more basic like the below would do
> the trick -- deferring the bringup of the secondary pools until later on in
> rand_initialize.

Firstly, wasn't this done before 8ef35c866f88 -- and initializing the NUMA
crng even if not enough entropy had been obtained yet?

Secondly, this approach seems works for small amounts of entropy submitted
to add_bootloader_randomness (e.g. for four calls with 8 bytes), but not for
larger quantities (e.g. for four calls with 64 bytes). Don't ask me why,
though.

Thirdly, this still does not fix the issue that only the second call to
add_bootloader_randomness() credits entropy.

Thanks,
	Dominik

  reply	other threads:[~2021-12-03 17:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  8:27 [PATCH] Revert "efi/random: Treat EFI_RNG_PROTOCOL output as bootloader randomness" Ivan T. Ivanov
2021-10-12  8:40 ` Dominik Brodowski
2021-10-13  7:30   ` [RESEND] " Ivan T. Ivanov
2021-10-13  7:50     ` Ard Biesheuvel
2021-10-13  8:05       ` Ivan T. Ivanov
2021-10-13  9:51       ` [RESEND] " Ivan T. Ivanov
2021-10-13  9:53         ` Ivan T. Ivanov
2021-10-13 13:23           ` Ivan T. Ivanov
2021-10-31  6:30   ` [PATCH] random: fix crash on multiple early calls to add_bootloader_randomness() Dominik Brodowski
2021-10-31 12:33     ` Ard Biesheuvel
2021-11-03  7:14       ` Dominik Brodowski
2021-11-03  7:27         ` Ard Biesheuvel
2021-11-05  6:04           ` Dominik Brodowski
2021-11-03  7:17   ` [PATCH v2] " Dominik Brodowski
2021-11-05  6:04   ` [PATCH v3] " Dominik Brodowski
2021-11-24 12:32     ` Ivan T. Ivanov
2021-12-02 11:35   ` [PATCH v3, resend] " Dominik Brodowski
2021-12-02 16:55     ` Jason A. Donenfeld
2021-12-03  7:58       ` [PATCH v4] " Dominik Brodowski
2021-12-03 15:39         ` Jason A. Donenfeld
2021-12-03 16:47           ` Jason A. Donenfeld
2021-12-03 17:01             ` Dominik Brodowski [this message]
2021-12-06  8:14           ` Ivan T. Ivanov
2021-12-30 18:05             ` Jason A. Donenfeld
2022-01-04 15:06               ` Ivan T. Ivanov
2021-12-06  5:42         ` Hsin-Yi Wang
2021-12-06 20:57           ` [PATCH v5] " Dominik Brodowski
2021-12-07  7:09             ` Hsin-Yi Wang
2021-12-07  7:14               ` Dominik Brodowski
2021-12-07 17:22             ` Jason A. Donenfeld
2021-12-20 14:48               ` 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=YapNd0byhBcnABei@light.dominikbrodowski.net \
    --to=linux@dominikbrodowski.net \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=hsinyi@chromium.org \
    --cc=iivanov@suse.de \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).