linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Stephan Mueller <smueller@chronox.de>
Cc: Linux Kernel Developers List <linux-kernel@vger.kernel.org>,
	herbert@gondor.apana.org.au, andi@firstfloor.org,
	sandyinchina@gmail.com, cryptography@lakedaemon.net,
	jsd@av8n.com, hpa@zytor.com, linux-crypto@vger.kernel.org
Subject: Re: [PATCH 2/5] random: make /dev/urandom scalable for silly userspace programs
Date: Mon, 30 May 2016 13:29:15 -0400	[thread overview]
Message-ID: <20160530172915.GH12629@thunk.org> (raw)
In-Reply-To: <5245285.5ppKq7E4P6@tauon.atsec.com>

On Mon, May 30, 2016 at 08:03:59AM +0200, Stephan Mueller wrote:
> >  static int rand_initialize(void)
> >  {
> > +#ifdef CONFIG_NUMA
> > +	int i;
> > +	int num_nodes = num_possible_nodes();
> > +	struct crng_state *crng;
> > +
> > +	crng_node_pool = kmalloc(num_nodes * sizeof(void *),
> > +				 GFP_KERNEL|__GFP_NOFAIL);
> > +
> > +	for (i=0; i < num_nodes; i++) {
> > +		crng = kmalloc(sizeof(struct crng_state),
> > +			       GFP_KERNEL | __GFP_NOFAIL);
> > +		initialize_crng(crng);
> 
> Could you please help me understand the logic flow here: The NUMA secondary 
> DRNGs are initialized before the input/blocking pools and the primary DRNG.
> 
> The initialization call uses get_random_bytes() for the secondary DRNGs. But 
> since the primary DRNG is not yet initialized, where does the get_random_bytes 
> gets its randomness from?

Yeah, I screwed up.  The hunk of code staring with "crng_node_pool =
kmalloc(..." and the for loop afterwards should be moved to after
_initialize_crng().  Serves me right for not testing CONFIG_NUMA
before sending out the patches.

This is *not* about adding entropy; as you've noted, this is done very
early in boot up, before there has been any chance for any kind of
entropy to be collected in any of the input pools.  It's more of a
insurance policy just in case on some platform, if it turns out that
assuming a bit's worth of entropy per interrupt was hopelessly
over-optimistic, at least the starting point will be different across
different kernels (and maybe different boot times, but on the sorts of
platforms where I'm most concerned, there may not be a real-time clock
and almost certainly not a architectural hwrng in the CPU).

	      		      	       - Ted

  reply	other threads:[~2016-05-30 17:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30  5:39 [PATCH-v3 0/5] random: replace urandom pool with a CRNG Theodore Ts'o
2016-05-30  5:39 ` [PATCH 1/5] random: replace non-blocking pool with a Chacha20-based CRNG Theodore Ts'o
2016-05-30  5:39 ` [PATCH 2/5] random: make /dev/urandom scalable for silly userspace programs Theodore Ts'o
2016-05-30  6:03   ` Stephan Mueller
2016-05-30 17:29     ` Theodore Ts'o [this message]
2016-05-30  5:39 ` [PATCH 3/5] random: add interrupt callback to VMBus IRQ handler Theodore Ts'o
2016-05-30  5:39 ` [PATCH 4/5] random: add backtracking protection to the CRNG Theodore Ts'o
2016-05-30  5:39 ` [PATCH 5/5] random: properly align get_random_int_hash Theodore Ts'o
2016-05-30 17:53 ` [PATCH-v3 0/5] random: replace urandom pool with a CRNG Andi Kleen
2016-05-30 20:59   ` Theodore Ts'o

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=20160530172915.GH12629@thunk.org \
    --to=tytso@mit.edu \
    --cc=andi@firstfloor.org \
    --cc=cryptography@lakedaemon.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jsd@av8n.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandyinchina@gmail.com \
    --cc=smueller@chronox.de \
    /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).