Message ID | 20220209011919.493762-10-Jason@zx2c4.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Herbert Xu |
Headers | show |
Series | random: cleanups around per-cpu crng & rdrand | expand |
On Wed, Feb 09, 2022 at 02:19:19AM +0100, Jason A. Donenfeld wrote: > 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(-) > Reviewed-by: Eric Biggers <ebiggers@google.com> - Eric
diff --git a/drivers/char/random.c b/drivers/char/random.c index f7f9cbfe13f7..e09874c511d0 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1305,7 +1305,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;
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(-)