All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
To: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>,
	Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
Subject: [PATCH 1/1] getrandom.2: rework paragraphs marked with FIXME
Date: Thu, 22 Jan 2015 20:30:46 +0100	[thread overview]
Message-ID: <1421955046-8296-1-git-send-email-xypron.glpk@gmx.de> (raw)
In-Reply-To: <CAKgNAkiQUXFZ82jDNqEPxpBmdkKOg03uQXg=iEuUNzg0rvgkZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

The patch clarifies when blocking may occur while calling
getrandom().

Signed-off-by: Heinrich Schuchardt <xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
---
 man2/getrandom.2 | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/man2/getrandom.2 b/man2/getrandom.2
index d01502e..cfbbf5f 100644
--- a/man2/getrandom.2
+++ b/man2/getrandom.2
@@ -55,20 +55,17 @@ Therefore
 should not be used for Monte Carlo simulations or other
 programs/algorithms which are doing probabilistic sampling.
 
-.\" FIXME is the following paragraph correct?
 By default,
 .BR getrandom ()
 draws entropy from the
 .IR /dev/urandom
-pool, and, if that pool has been initialized and
-.IR buflen
-is less than or equal to 256 (see NOTES, below),
-then the call never blocks when drawing from that pool
-and always returns the number of bytes requested in
-.IR buflen .
+pool.
 This behavior can be changed via the
 .I flags
 argument.
+If the
+.IR /dev/urandom
+pool has been initialized, reading from that pool never blocks.
 
 The
 .I flags
@@ -157,17 +154,27 @@ was introduced in version 3.17 of the Linux kernel.
 This system call is Linux-specific.
 .SH NOTES
 .SS Interruption by a signal handler
-.\" FIXME Here, I think there needs to be an opening paragraph that describes
-.\" the cases where getrandom() can block. This should cover the cases with
-.\" GRND_RANDOM and without GRND_RANDOM. Reading the existing page, I am
-.\" still not completely confident that I know what the cases are.
+A call to
+.BR getrandom ()
+can only block when called without the
+.B GRND_NONBLOCK
+flag.
+When reading from
+.I /dev/urandom
+.RB ( GRND_RANDOM
+is not set)
+blocking only occurs if the entropy pool has not been initialized yet.
+When reading from
+.I /dev/random
+.RB ( GRND_RANDOM
+is set)
+blocking occurs if not enough random bytes are available.
+
 The reaction of
 .BR getrandom ()
 in case of an interruption of a blocking call by a signal
 when reading from
 .I /dev/urandom
-.RB ( GRND_RANDOM
-is not set)
 depends on the initialization state of the entropy buffer
 and on the request size
 .IR buflen .
@@ -184,8 +191,6 @@ Instead, it will return all of the bytes that have been requested.
 .PP
 When reading from
 .I /dev/random
-.RB ( GRND_RANDOM
-is set)
 these guarantees do
 .I not
 apply.
-- 
2.1.4

--
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:[~2015-01-22 19:30 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-13 13:15 [PATCH 1/1] getrandom(2) : new man page Heinrich Schuchardt
     [not found] ` <1410614156-16175-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2014-09-29 15:22   ` Michael Kerrisk (man-pages)
     [not found]     ` <5429791D.6080903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-09-29 15:52       ` Theodore Ts'o
2014-09-30  0:38       ` Aw: " Heinrich Schuchardt
2014-09-30  9:22         ` Michael Kerrisk (man-pages)
     [not found]           ` <542A7645.8070802-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-03  0:13             ` [PATCH 0/3] getrandom.2: new manpage Heinrich Schuchardt
     [not found]               ` <1412295197-8100-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2014-10-03  0:15                 ` [PATCH 1/3] " Heinrich Schuchardt
2014-10-28 11:37                   ` Michael Kerrisk (man-pages)
2014-10-28 11:37                     ` Michael Kerrisk (man-pages)
     [not found]                   ` <1412295313-8198-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2014-10-06 18:13                     ` Michael Kerrisk (man-pages)
2014-10-28 19:51                     ` Michael Kerrisk (man-pages)
2014-11-11 11:44                   ` Michael Kerrisk (man-pages)
2014-11-11 16:19                     ` [PATCH] getrandom.2: treatment of interrupts Heinrich Schuchardt
2014-11-11 16:19                       ` Heinrich Schuchardt
2014-11-16 15:55                       ` Michael Kerrisk (man-pages)
2014-11-16 15:55                         ` Michael Kerrisk (man-pages)
2014-11-22 11:28                         ` Heinrich Schuchardt
2014-11-22 11:28                           ` Heinrich Schuchardt
2014-11-29  9:12                           ` [PATCH 1/1] urandom: handle signals immediately Heinrich Schuchardt
2014-12-19 16:57                             ` Theodore Ts'o
2014-12-19 18:55                               ` Heinrich Schuchardt
2015-01-10 13:23                     ` [PATCH 1/3] getrandom.2: new manpage Michael Kerrisk (man-pages)
2015-01-10 13:23                       ` Michael Kerrisk (man-pages)
     [not found]                       ` <CAKgNAkiQUXFZ82jDNqEPxpBmdkKOg03uQXg=iEuUNzg0rvgkZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-22 18:30                         ` [PATCH 1/1] getrandom.2: mention bug concerning treatment of interrupts Heinrich Schuchardt
     [not found]                           ` <1421951410-6420-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2015-01-22 19:58                             ` Michael Kerrisk (man-pages)
2015-01-22 19:30                         ` Heinrich Schuchardt [this message]
     [not found]                           ` <1421955046-8296-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2015-01-23  6:01                             ` [PATCH 1/1] getrandom.2: rework paragraphs marked with FIXME Michael Kerrisk (man-pages)
2014-10-03  0:15                 ` [PATCH 2/3] random.3: SEE ALSO getrandom.2 Heinrich Schuchardt
     [not found]                   ` <1412295324-8241-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2014-10-28 14:37                     ` Michael Kerrisk (man-pages)
2014-10-03  0:15                 ` [PATCH 3/3] random.4: " Heinrich Schuchardt
     [not found]                   ` <1412295335-8287-1-git-send-email-xypron.glpk-Mmb7MZpHnFY@public.gmane.org>
2014-10-28 14:38                     ` 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=1421955046-8296-1-git-send-email-xypron.glpk@gmx.de \
    --to=xypron.glpk-mmb7mzphnfy@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@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.