From: Eric Biggers <ebiggers@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
Theodore Ts'o <tytso@mit.edu>,
Dominik Brodowski <linux@dominikbrodowski.net>,
Jann Horn <jannh@google.com>
Subject: Re: [RFC] Should writes to /dev/urandom immediately affect reads?
Date: Wed, 20 Sep 2023 12:32:03 -0700 [thread overview]
Message-ID: <20230920193203.GA914@sol.localdomain> (raw)
In-Reply-To: <CAHk-=wja26UmHQCu48n_HN5t5w3fa6ocm5d_VrJe6-RhCU_x9A@mail.gmail.com>
Hi Linus,
On Wed, Sep 20, 2023 at 11:48:26AM -0700, Linus Torvalds wrote:
> On Tue, 19 Sept 2023 at 23:06, Eric Biggers <ebiggers@kernel.org> wrote:
> >
> > This would be the potential change, BTW:
>
> Entirely regardless of your fundamental question, no, that's not the
> potential change.
>
> That causes a crng_reseed() even if the write fails completely and
> returns -EFAULT.
>
> So at a *minimum*, I'd expect the patch to be be something like
>
> memzero_explicit(block, sizeof(block));
> - return ret ? ret : -EFAULT;
> + if (!ret)
> + return -EFAULT;
> + crng_reseed(NULL);
> + return ret;
>
> but even then I'd ask
>
> - wouldn't we want some kind of minimum check?
>
> - do we really trust writes to add any actual entropy at all and at what point?
>
> which are admittedly likely the same question just in different guises.
Whether to credit entropy for writes to /dev/{u,}random is an unrelated topic,
and the answer is clearly "no, we must not, and we never have" (as I mentioned
in the second paragraph of my email). I understand the last discussion
https://lore.kernel.org/lkml/20220322191436.110963-1-Jason@zx2c4.com/T/#u
diverged into both topics, but they're not directly related. Reseeding the CRNG
just makes it up to date with the entropy pool; nothing more than that.
Yes, obviously there's no point in reseeding if nothing actually got added, so
we could skip the reseed in that case if we want to.
>
> Also, are there any relevant architectures where
> "try_to_generate_entropy()" doesn't work? IOW, why do you even care?
>
There are, as shown by the fact that the full unification of /dev/urandom and
/dev/random failed yet again. But similarly, that's unrelated. The actual
question, which I'm attempting to start a discussion about without getting
sidetracked into questions that may seem related but actually aren't, is simply
whether writes to /dev/{u,}random should immediately affect reads.
- Eric
next prev parent reply other threads:[~2023-09-20 19:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 6:06 [RFC] Should writes to /dev/urandom immediately affect reads? Eric Biggers
2023-09-20 18:48 ` Linus Torvalds
2023-09-20 19:32 ` Eric Biggers [this message]
2023-09-20 19:42 ` Linus Torvalds
2023-09-20 20:21 ` Eric Biggers
2023-09-20 20:32 ` Linus Torvalds
2023-09-20 20:41 ` Linus Torvalds
2023-09-21 21:57 ` David Laight
2023-09-20 20:45 ` Eric Biggers
2023-09-20 20:48 ` Linus Torvalds
2023-09-21 13:30 ` Theodore Ts'o
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=20230920193203.GA914@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=jannh@google.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).