From: "Theodore Ts'o" <tytso@mit.edu>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com,
herbert@gondor.apana.org.au, Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 1/3] Make /dev/urandom scalable
Date: Wed, 23 Sep 2015 17:10:05 -0400 [thread overview]
Message-ID: <20150923211005.GJ3318@thunk.org> (raw)
In-Reply-To: <1442963767-14945-1-git-send-email-andi@firstfloor.org>
On Tue, Sep 22, 2015 at 04:16:05PM -0700, Andi Kleen wrote:
>
> This patch changes the random driver to use distributed per NUMA node
> nonblocking pools. The basic structure is not changed: entropy is
> first fed into the input pool and later from there distributed
> round-robin into the blocking and non blocking pools. This patch extends
> this to use an dedicated non blocking pool for each node, and distribute
> evenly from the input pool into these distributed pools, in
> addition to the blocking pool.
>
> Then every urandom/getrandom user fetches data from its node local
> pool. At boot time when users may be still waiting for the non
> blocking pool initialization we use the node 0 non blocking pool,
> to avoid the need for different wake up queues.
What I would suggest is that we only create the per-NUMA node pools
until the original node 0 is marked as initialized (i.e., that it was
been initialized with 128 bits of randomness). At that point
initialize pools 1..n using the originial non-blocking pool by using
get_random_bytes() to fill up the pool. Once all of the pools are
initialized, only then set the nonblocking_node_pool variable. In
practice, especially for the large server systems, getting 128 bits of
randomness to initialize the primary non-blocking pool shouldn't take
long. On my laptop, it takes 4 seconds.
My concern, though, is that things like initialized ssh host keys
happen at boot time, so anything that weakens the random number
generator is a bad thing. (In practice, this isn't a problem
pre-systemd, but systemd speeds up the boot sequence quickly enough
that this is in fact a potential security problem.) We already have
the problem that systemd-udevd grabs random numbers before the random
pool is initialized:
[ 1.124926] random: systemd-udevd urandom read with 13 bits of entropy available
[ 4.137543] random: nonblocking pool is initialized
> The different per-node pools also start with different start
> states and diverge more and more over time, as they get
> feed different input data. So "replay" attacks are
> difficult after some time.
The problem is "after some time" happens after public keys get
generated, this isn't good for anything other than starving academics
publishing papers about weaknesses in the Linux's random number
generator. :-)
So I'd strongly prefer if we don't weaken the random number generator
boot-time initialization story, and the best way to do this is to wait
for a single non-blocking pool to be completely initialized, and then
use that pool to initialize the rest of the pools. If that means that
we don't have the full /dev/urandom scalability during the first few
seconds after the system is booted, to my mind that's a fair tradeoff.
Does that sound reasonable?
> For saving/restoring /dev/urandom, there is currently no mechanism
> to access the non local node pool (short of setting task affinity).
> This implies that currently the standard init/exit random save/restore
> scripts would only save node 0. On restore all pools are updates.
> So the entropy of non 0 gets lost over reboot. That seems acceptable
> to me for now (fixing this would need a new separate save/restore interface)
Yes, that's fine; I'm not really worried about that, since
getrandom(2) only provides a guarantee of initialized cryptographic
randomness, and that's what we should most care about.
- Ted
next prev parent reply other threads:[~2015-09-23 21:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 23:16 [PATCH 1/3] Make /dev/urandom scalable Andi Kleen
2015-09-22 23:16 ` [PATCH 2/3] random: Make input to output pool balancing per cpu Andi Kleen
2015-09-22 23:16 ` [PATCH 3/3] random: Add pool name to urandom_read trace point Andi Kleen
2015-09-22 23:25 ` [PATCH 1/3] Make /dev/urandom scalable Andi Kleen
2015-09-23 10:32 ` Rasmus Villemoes
2015-09-23 21:54 ` Andi Kleen
2015-09-23 19:40 ` Austin S Hemmelgarn
2015-09-23 23:28 ` Andi Kleen
2015-09-24 11:37 ` Austin S Hemmelgarn
2015-09-24 13:12 ` Theodore Ts'o
2015-09-24 16:00 ` Austin S Hemmelgarn
2015-09-24 16:52 ` Jeff Epler
2015-09-24 19:11 ` Austin S Hemmelgarn
2015-09-24 20:00 ` Jeff Epler
2015-09-24 20:14 ` Theodore Ts'o
2015-09-25 11:41 ` Austin S Hemmelgarn
2015-09-25 19:07 ` Austin S Hemmelgarn
2015-09-25 20:24 ` Theodore Ts'o
2015-09-29 12:06 ` Austin S Hemmelgarn
2015-09-29 11:57 ` Austin S Hemmelgarn
2015-09-23 21:10 ` Theodore Ts'o [this message]
2015-09-23 21:25 ` Andi Kleen
-- strict thread matches above, loose matches on Subject: below --
2015-09-24 17:19 Updated scalable urandom patchkit Andi Kleen
2015-09-24 17:19 ` [PATCH 1/3] Make /dev/urandom scalable Andi Kleen
2015-09-30 14:40 ` Rasmus Villemoes
2015-10-06 22:05 Andi Kleen
2016-02-10 23:01 Scalable random patchkit revisited Andi Kleen
2016-02-10 23:01 ` [PATCH 1/3] Make /dev/urandom scalable Andi Kleen
2016-03-01 5:17 Andi Kleen
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=20150923211005.GJ3318@thunk.org \
--to=tytso@mit.edu \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=herbert@gondor.apana.org.au \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.