All of lore.kernel.org
 help / color / mirror / Atom feed
From: "George Spelvin" <linux-gpGsJRJZ3PBBDgjK7y7TUQ@public.gmane.org>
To: linux-gpGsJRJZ3PBBDgjK7y7TUQ@public.gmane.org,
	mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	nmav-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org,
	tytso-3s7WtUTddSA@public.gmane.org
Subject: Re: [PATCH] Update the random(4) documentation towards a more accurate view on /dev/urandom
Date: 26 Apr 2016 12:58:47 -0400	[thread overview]
Message-ID: <20160426165847.5804.qmail@ns.horizon.com> (raw)
In-Reply-To: <1461681983.15804.76.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Nikos Mavrogiannopoulos wrote:
> On Mon, 2016-04-25 at 11:46 -0400, George Spelvin wrote:
>> Removing the examples of high quality randomness I'm less fond of;
>> the whole idea is to inform people who don't quite understand what
>> the general terms mean.  Good enough for one-time pads is a design
>> goal of /dev/random.

> If that's about documenting a design goal I'd prefer to move it out of
> the main text for 2 reasons. (a) There is no practical crypto system
> using one time pads, thus mentioning it in the main body only creates
> confusion (b), one time pad is such a theoretical construction that any
> real algorithm wouldn't implement it.

The original (removed by your patch) line was:

-high quality randomness such as one-time pad or key generation.

It's not the words "one-time pad" I'm attached to, but the specific
examples of when "high-quality randomness" is required.  A big point is
to teach people *how* to use it, and without those examples, when would
anyone think "my application wants low-quality randomness"?

You're right that a one-time pad is impractical, but it's still
a common and familiar pedagogical example, and more importantly
something that a person wondering which to use can see that their
application is NOT.

Your proposed patch *also* deleted the other usage example at the end:

-should be used for everything except long-lived GPG/SSL/SSH keys.

which really reduces the value of the man page as a guide to people
who aren't crypto experts.

>> The bit about early boot is actually not as much of an issue as you
>> think.
>>
>> Even /dev/urandom will stall early on boot until a minimum initial seed
>> (128 bits at present) has been acumulated.  (grep for "urandom_init_wait")

> No it will not. We notice often the keys for sshd being generated
> *before* the kernel logs that the random pool has been
> initialized.

H'm... observation definitely trumps theoretical predictions based on
reading the code.

Is that a documentation problem or a code bug, or something I'm not
understanding properly?  If you look for that symbol in the source
it definitely looks like it's supposed to wait for initial seeding.
And ssh-keygen uses /dev/urandom.

The getrandom(2) man page also documents the block-on-startup behavior.

The driver wakes up the sleeping readers *before* printing
the message.  Is it possible that syslog is just losing the race?

>> How about something more like (draft, not final edit):
>> 
>>  A read from the \fI/dev/urandom\fP device will not block
>>  waiting for more entropy.
>> +If the estimated fresh entropy is not sufficient, a
>> \fI/dev/urandom\fP
>> +will produce output anyway, relying on the cryptographic primitives
>> in
>> +the driver's pseudo-random number generator to ensure that the
>> output,
>> +although correlated with previous output in an information theoretic
>> +sense (it exceeds the unicity distance), is secure for all practical
>> +purposes.

> What is the purpose of this text? To whom does it target?

To replace the text

-If there is not sufficient entropy, a pseudorandom number generator is used
-to create the requested bytes.

or

+If the estimated fresh entropy is not sufficient, a pseudorandom number generator is
+used to create the requested bytes.

with something that doesn't imply a mode switch.

I labelled it "draft" because I wasn't really thrilled with the wording,
myself, but I thought it gave the general idea and wasn't worth massaging
into editorial perfection since it was due to get torn apart anyway.

Can you think of better wording?  I'm all for keeping it simple, but
not at the expense of seriously misleading people.

> I wouldn't like to get into such details about the device in the manpage,
> but if you would like a section studying the theoretical properties of
> /dev/urandom I'd again suggest to keep it separate and elaborate. What
> is on the text above is certainly not complete analysis and is certainly
> not targetting administrators and developers who would like to understand
> what this device does.

A reorganization might indeed be a good way forward; I was examining 
your changes without stepping back and considering the whole forest.

Shall I take a stab at it?

>> I don't like the bit about "use /dev/random or getrandom(2)"; while
>> getrandom(2) should be mentioned in "see also", the equivalent is
>> "getrandom(..., GRND_RANDOM)".   It's the flag, no the syscall.

> It is the syscall. According the description in getrandom(2):
> "If the pool has not yet been initialized, then the call blocks,
> unless GRND_RANDOM is specified in flags."

1. You have a buggy man page.  The corrected one says "If the pool has
   not yet been initialized, then the call blocks, unless GRND_NONBLOCK
   is specified in flags."

2. I stand by what I wrote above.  Without the GRND_RANDOM flag,
   getrandom() access the nonblocking pool (/dev/urandom).

>> I strongly dislike the deletion of the "as a general rule" advice.
>> Specific recommendations are very valuable.

> This advice despite being present for so long, is widely ignored as
> /dev/urandom is used unconditionally by all software generating keys
> (SSH/SSL), gnupg being the exception.

No, it's not being ignored.  The advice isn't "use /dev/random for
SSH keys", but "*don't* use /dev/random for anything *except* SSH
keys".  The "(and maybe not even then)" part is implicit, but much
less of a concern.

The audience is not the authors of ssh, libssl, or gnupg; they know
what they're doing.  The audience is everyone *else*, and I think
specific examples really help there.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-04-26 16:58 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25  8:48 [PATCH] Update the random(4) documentation towards a more accurate view on /dev/urandom Nikos Mavrogiannopoulos
     [not found] ` <1461574090.32558.45.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-25 15:46   ` George Spelvin
     [not found]     ` <20160425154605.7445.qmail-HzZAx2gCgqrSUeElwK9/Pw@public.gmane.org>
2016-04-26 14:46       ` Nikos Mavrogiannopoulos
     [not found]         ` <1461681983.15804.76.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-26 16:58           ` George Spelvin [this message]
     [not found]             ` <20160426165847.5804.qmail-HzZAx2gCgqrSUeElwK9/Pw@public.gmane.org>
2016-11-09 15:26               ` Michael Kerrisk (man-pages)
     [not found]                 ` <8a990d27-1fc2-8358-f9d3-c9474d6d8616-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-10  8:21                   ` Nikos Mavrogiannopoulos
     [not found]                     ` <1478766102.2642.12.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-10 11:29                       ` Michael Kerrisk (man-pages)
2016-08-01 11:48   ` Nikos Mavrogiannopoulos
     [not found]     ` <1470052099.2926.6.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-20  8:37       ` Nikos Mavrogiannopoulos
     [not found]         ` <1476952646.2522.10.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-21  7:21           ` Michael Kerrisk (man-pages)
     [not found]             ` <8a5e82db-6f8a-2426-4a68-feab205bca57-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-21 14:07               ` Stephan Mueller
     [not found]                 ` <2402524.TIv9Kdt40z-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>
2016-10-21 14:38                   ` Nikos Mavrogiannopoulos
     [not found]                     ` <1477060710.3888.14.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-21 14:55                       ` Stephan Mueller
2016-10-21 16:33                   ` Theodore Ts'o
     [not found]                     ` <20161021163314.cvhjgr4s7lfzdsve-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-10-21 16:50                       ` Stephan Mueller
     [not found]                         ` <4610047.a51zB7LfZj-gNvIQDDl/k7Ia13z/PHSgg@public.gmane.org>
2016-10-21 17:56                           ` Theodore Ts'o
     [not found]                             ` <20161021175633.5x5mp2xv3wq4ejjf-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-10-21 18:00                               ` Stephan Mueller
2016-11-01  9:35               ` Nikos Mavrogiannopoulos
     [not found]                 ` <1477992912.3769.22.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-09 14:58                   ` Michael Kerrisk (man-pages)
2016-11-09 15:23           ` Michael Kerrisk (man-pages)
     [not found]             ` <b07fb334-149d-cf65-74f3-1d1951e5981b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-10  8:54               ` Nikos Mavrogiannopoulos
     [not found]                 ` <1478768067.2642.23.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-10  9:11                   ` Laurent Georget
     [not found]                     ` <3b7ba39b-0434-47ca-7857-257f3c99266b-AyimVQWTEHzsq35pWSNszA@public.gmane.org>
2016-11-10 11:56                       ` Michael Kerrisk (man-pages)
2016-11-10 11:50                   ` Michael Kerrisk (man-pages)
     [not found]                     ` <e5c1f87c-aad0-b526-a346-74348a36c2a3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-10 11:53                       ` Nikos Mavrogiannopoulos
     [not found]                         ` <1478778837.2642.26.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-10 11:56                           ` Michael Kerrisk (man-pages)
     [not found]                             ` <05152136-6943-8ada-3d65-51ef4ce9c1b1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-10 14:19                               ` Michael Kerrisk (man-pages)
2016-11-10 14:20                               ` [PATCH] random.4: Improve discussion or urandom, blocking reads, and signals Michael Kerrisk (man-pages)
     [not found]                                 ` <4a8c573c-0c19-29d0-248e-74c088968806-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-11 10:28                                   ` Laurent Georget
     [not found]                                     ` <d5eca965-c8b9-51e5-6acb-172e47f85ba0-vbcOdlJ0SulGWvitb5QawA@public.gmane.org>
2016-11-11 11:51                                       ` Michael Kerrisk (man-pages)
2016-11-12 12:25                                       ` New random(7) page for review Michael Kerrisk (man-pages)
     [not found]                                         ` <cb25213c-a70d-cbf1-6a42-959dcdc1f202-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-12 14:03                                           ` Laurent Georget
     [not found]                                             ` <54e6e40c-b840-c773-e739-7faed9664411-AyimVQWTEHzsq35pWSNszA@public.gmane.org>
2016-11-15  6:19                                               ` Michael Kerrisk (man-pages)
2016-11-13 22:20                                           ` Theodore Ts'o
     [not found]                                             ` <20161113222041.ypnz3sdm3fmjprnn-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-11-15  6:41                                               ` Michael Kerrisk (man-pages)
2016-11-14  8:06                                           ` Nikos Mavrogiannopoulos
     [not found]                                             ` <1479110801.2624.2.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-15  6:10                                               ` Michael Kerrisk (man-pages)
2016-11-11 16:05                                   ` [PATCH] random.4: Improve discussion or urandom, blocking reads, and signals Theodore Ts'o
     [not found]                                     ` <20161111160514.yrlfteowdz4qar76-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2016-11-12 10:54                                       ` Michael Kerrisk (man-pages)

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=20160426165847.5804.qmail@ns.horizon.com \
    --to=linux-gpgsjrjz3pbbdgjk7y7tuq@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=nmav-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.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.