From: "Theodore Ts'o" <tytso@mit.edu>
To: Denys Vlasenko <dvlasenk@redhat.com>
Cc: "H. Peter Anvin" <hpa@linux.intel.com>,
Denys Vlasenko <vda.linux@googlemail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: random: /dev/random often returns short reads
Date: Wed, 18 Jan 2017 13:07:36 -0500 [thread overview]
Message-ID: <20170118180735.74diazvujsjlqf5m@thunk.org> (raw)
In-Reply-To: <2bc270ee-9f42-b4b3-a347-3a7a758d5d1f@redhat.com>
On Wed, Jan 18, 2017 at 04:44:54PM +0100, Denys Vlasenko wrote:
> In this case, what code does is it returns fewer bytes,
> even though *it has enough random bytes to return the full request*.
>
> This happens because the patch which added more conservative
> accounting, while containing technically correct accounting per se,
> it forgot to take in the account another part of the code
> which was relying on the previous, simplistic logic
> "if we add N random bytes to a pool, now it has +N random bytes".
>
> In my opinion, it should have changed that part of code simultaneously
> with introducing more conservative accounting.
In the ideal world, yes. I've acknowledged this is a bug, in the "be
conservative in what you send, liberal in what you receive" sense..
But no one complained for three year, and userspace needs to be able
to retry short reads instead of immediately erroring out.
The problem is changing that code to figure out exactly how many bytes
you need to get in order to have N random bytes is non-trivial. So
our choices are:
1) Transfer more bytes than might be needed to the secondary pool,
which results in resource stranding --- since entropy in the secondary
pool isn't available for reseeding the CRNG. OTOH, given that we're
now using the CRNG solution, and we're only reseeding every five
minutes, I'm not actually all that worried about stranding some extra
entropy bits in the blocking pool, since that's only going to happen
if we have people *using* the /dev/random pool, and so that entropy
will likely be used eventually anyway.
2) Transfer bytes without using the conservative entropy "overwrite"
calculation if the blocking pool is mostly empty. This means we will
be over-estimating the entropy in that pool, which is unfortunate.
One could argue that all of the cases where people have been whining
about this, they are using HAVEGED which is providing pretend entropy
based on the presumed unpredictability of Intel cahce timing, so
careful entropy calculations is kind of silly anyway. However, there
might be some people who really are trying to do carefule entropy
measurement, so compromising this isn't really a great idea.
3) Make reads of /dev/random block, or have it try multiple times to
call extract_entropy() and transfering secondary entropy. This will
work, but it is less efficient, and it makes the code a bit uglier.
4) Close the bug as WAI, and tell Red Hat's paying customers to go
pound sand. Since they should be fixing their userspace, and why
changing OpenSSL to use /dev/random, but not changing it to fix the
damned bug in OpenSSL isn't OK, is crazy FIPS certification talk.
I'm leaning a bit towards 1 if we have to do something (which is my
proposed, untested patch).
- Ted
next prev parent reply other threads:[~2017-01-18 18:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 18:50 Denys Vlasenko
2017-01-16 18:52 ` Denys Vlasenko
2017-01-17 4:36 ` Theodore Ts'o
2017-01-17 8:21 ` Denys Vlasenko
2017-01-17 17:15 ` Theodore Ts'o
2017-01-17 17:34 ` Denys Vlasenko
2017-01-17 22:29 ` H. Peter Anvin
2017-01-17 23:41 ` Theodore Ts'o
2017-01-18 1:54 ` H. Peter Anvin
2017-01-18 15:44 ` Denys Vlasenko
2017-01-18 18:07 ` Theodore Ts'o [this message]
2017-01-19 21:45 ` Denys Vlasenko
2017-01-20 3:17 ` H. Peter Anvin
2017-02-15 17:55 ` Denys Vlasenko
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=20170118180735.74diazvujsjlqf5m@thunk.org \
--to=tytso@mit.edu \
--cc=dvlasenk@redhat.com \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vda.linux@googlemail.com \
/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
all inboxes | Powered by JetHome®