From: Eric Biggers <ebiggers@kernel.org>
To: "Guozihua (Scott)" <guozihua@huawei.com>
Cc: linux-crypto@vger.kernel.org, luto@kernel.org, tytso@mit.edu,
"Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: Re: Inquiry about the removal of flag O_NONBLOCK on /dev/random
Date: Mon, 18 Jul 2022 20:47:15 -0700 [thread overview]
Message-ID: <YtYpQ1gf23mxIiYH@sol.localdomain> (raw)
In-Reply-To: <d49d35f5-8eaf-d5e8-7443-ac896a946db7@huawei.com>
On Mon, Jul 18, 2022 at 04:52:59PM +0800, Guozihua (Scott) wrote:
> On 2022/7/14 15:33, Guozihua (Scott) wrote:
> > Hi Community,
> >
> > Recently we noticed the removal of flag O_NONBLOCK on /dev/random by
> > commit 30c08efec888 ("random: make /dev/random be almost like
> > /dev/urandom"), it seems that some of the open_source packages e.g.
> > random_get_fd() of util-linux and __getrandom() of glibc. The man page
> > for random() is not updated either.
>
> Correction: I mean various open source packages are still using O_NONBLOCK
> flag while accessing /dev/random
> >
> > Would anyone please kindly provide some background knowledge of this
> > flag and it's removal? Thanks!
> >
This was changed a while ago, in v5.6. /dev/random no longer recognizes
O_NONBLOCK because it no longer blocks, except before the entropy pool has been
initialized.
(I don't know why O_NONBLOCK stopped being recognized *before* the entropy pool
has been initialized; it's either an oversight, or it was decided it doesn't
matter. Probably the latter, since I can't think of a real use case for using
O_NONBLOCK on /dev/random.)
The random(4) man page is indeed in need of an update, not just for this reason
but for some other reasons too.
The util-linux code which you mentioned is opening /dev/random with O_NONBLOCK
if opening /dev/urandom fails, which is pretty much pointless. Perhaps the
author thought that /dev/random with O_NONBLOCK is equivalent to /dev/urandom
(it's not). The glibc code, if you mean sysdeps/mach/hurd/getrandom.c, is
actually code written for GNU Hurd, not for Linux, so it's not relevant.
- Eric
next prev parent reply other threads:[~2022-07-19 3:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-14 7:33 Inquiry about the removal of flag O_NONBLOCK on /dev/random Guozihua (Scott)
2022-07-18 8:52 ` Guozihua (Scott)
2022-07-19 3:47 ` Eric Biggers [this message]
2022-07-19 8:06 ` Guozihua (Scott)
2022-07-19 11:01 ` Jason A. Donenfeld
2022-07-21 3:50 ` Guozihua (Scott)
2022-07-21 4:07 ` Eric Biggers
2022-07-21 6:44 ` Guozihua (Scott)
2022-07-21 6:50 ` Eric Biggers
2022-07-21 10:37 ` Jason A. Donenfeld
2022-07-21 11:30 ` Guozihua (Scott)
2022-07-26 7:43 ` Guozihua (Scott)
2022-07-26 11:08 ` Jason A. Donenfeld
2022-07-26 11:33 ` Guozihua (Scott)
2022-07-28 8:24 ` Guozihua (Scott)
2022-09-06 7:14 ` Guozihua (Scott)
2022-09-06 10:16 ` Jason A. Donenfeld
2022-09-07 13:03 ` Jason A. Donenfeld
2022-09-08 3:31 ` Guozihua (Scott)
2022-09-08 9:51 ` Jason A. Donenfeld
2022-09-08 10:40 ` Jason A. Donenfeld
2022-09-08 14:26 ` [PATCH] random: restore O_NONBLOCK support Jason A. Donenfeld
2022-09-19 10:27 ` Inquiry about the removal of flag O_NONBLOCK on /dev/random Guozihua (Scott)
2022-09-19 10:40 ` Jason A. Donenfeld
2022-09-19 10:45 ` Guozihua (Scott)
2022-07-21 11:09 ` Theodore Ts'o
2022-07-21 11:30 ` Guozihua (Scott)
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=YtYpQ1gf23mxIiYH@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=guozihua@huawei.com \
--cc=linux-crypto@vger.kernel.org \
--cc=luto@kernel.org \
--cc=tytso@mit.edu \
/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