public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
	Theodore Ts'o <tytso@mit.edu>,
	Dominik Brodowski <linux@dominikbrodowski.net>
Subject: [PATCH v1 7/7] random: remove outdated INT_MAX >> 6 check in urandom_read()
Date: Tue,  8 Feb 2022 16:53:35 +0100	[thread overview]
Message-ID: <20220208155335.378318-8-Jason@zx2c4.com> (raw)
In-Reply-To: <20220208155335.378318-1-Jason@zx2c4.com>

In 79a8468747c5 ("random: check for increase of entropy_count because of
signed conversion"), a number of checks were added around what values
were passed to account(), because account() was doing fancy fixed point
fractional arithmetic, and a user had some ability to pass large values
directly into it. One of things in that commit was limiting those values
to INT_MAX >> 6.

However, for several years now, urandom reads no longer touch entropy
accounting, and so this check serves no purpose. The current flow is:

urandom_read_nowarn()-->get_random_bytes_user()-->chacha20_block()

We arrive at urandom_read_nowarn() in the first place either via
ordinary fops, which limits reads to MAX_RW_COUNT, or via getrandom()
which limits reads to INT_MAX.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/char/random.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index ac22dc94b037..fa366ab38263 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1324,7 +1324,6 @@ static ssize_t urandom_read_nowarn(struct file *file, char __user *buf,
 {
 	int ret;
 
-	nbytes = min_t(size_t, nbytes, INT_MAX >> 6);
 	ret = get_random_bytes_user(buf, nbytes);
 	trace_urandom_read(8 * nbytes, 0, input_pool.entropy_count);
 	return ret;
-- 
2.35.0


      parent reply	other threads:[~2022-02-08 15:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 15:53 [PATCH v1 0/7] random: cleanups around per-cpu crng & rdrand Jason A. Donenfeld
2022-02-08 15:53 ` [PATCH v1 1/7] random: use RDSEED instead of RDRAND in entropy extraction Jason A. Donenfeld
2022-02-08 23:07   ` Eric Biggers
2022-02-08 15:53 ` [PATCH v1 2/7] random: get rid of secondary crngs Jason A. Donenfeld
2022-02-08 15:53 ` [PATCH v1 3/7] random: inline leaves of rand_initialize() Jason A. Donenfeld
2022-02-08 23:08   ` Eric Biggers
2022-02-08 15:53 ` [PATCH v1 4/7] random: ensure early RDSEED goes through mixer on init Jason A. Donenfeld
2022-02-08 23:10   ` Eric Biggers
2022-02-08 15:53 ` [PATCH v1 5/7] random: do not xor RDRAND when writing into /dev/random Jason A. Donenfeld
2022-02-08 23:11   ` Eric Biggers
2022-02-08 15:53 ` [PATCH v1 6/7] random: use simpler fast key erasure flow on per-cpu keys Jason A. Donenfeld
2022-02-08 23:39   ` Eric Biggers
2022-02-09  0:21     ` Jason A. Donenfeld
2022-02-08 15:53 ` Jason A. Donenfeld [this message]

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=20220208155335.378318-8-Jason@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --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