From: Dominik Brodowski <linux@dominikbrodowski.net>
To: Matt Mackall <mpm@selenic.com>, Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
"Jason A . Donenfeld" <Jason@zx2c4.com>
Subject: [PATCH 2/6] hw_random: read() callback must be called for size of 32 or more bytes
Date: Mon, 24 Jan 2022 21:29:47 +0100 [thread overview]
Message-ID: <20220124202951.28579-2-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20220124202951.28579-1-linux@dominikbrodowski.net>
According to <linux/hw_random.h>, the @max parameter of the ->read
callback "is a multiple of 4 and >= 32 bytes". That promise was not
kept by add_early_randomness(), which only asked for 16 bytes. As
rng_buffer_size() is at least 32, we can simply ask for 32 bytes.
Cc: Matt Mackall <mpm@selenic.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
drivers/char/hw_random/core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index e860e044b19e..c2d260b5dd92 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -64,10 +64,9 @@ static size_t rng_buffer_size(void)
static void add_early_randomness(struct hwrng *rng)
{
int bytes_read;
- size_t size = min_t(size_t, 16, rng_buffer_size());
mutex_lock(&reading_mutex);
- bytes_read = rng_get_data(rng, rng_buffer, size, 0);
+ bytes_read = rng_get_data(rng, rng_buffer, 32, 0);
mutex_unlock(&reading_mutex);
if (bytes_read > 0)
add_device_randomness(rng_buffer, bytes_read);
--
2.34.1
next prev parent reply other threads:[~2022-01-24 20:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 20:29 [PATCH 1/6] hw_random: explicit ordering of initcalls Dominik Brodowski
2022-01-24 20:29 ` Dominik Brodowski [this message]
2022-01-24 20:29 ` [PATCH 3/6] hw_random: use rng_fillbuf in add_early_randomness() Dominik Brodowski
2022-01-24 20:29 ` [PATCH 4/6] hw_random: only set cur_rng_set_by_user if it is working Dominik Brodowski
2022-01-24 20:29 ` [PATCH 5/6] hw_random: break out of hwrng_fillfn if current rng is not trusted Dominik Brodowski
2022-01-24 20:29 ` [PATCH 6/6] hw_random: credit entropy for low quality sources of randomness Dominik Brodowski
2022-01-28 7:02 ` [PATCH v2 " Dominik Brodowski
2022-02-05 4:30 ` [PATCH 1/6] hw_random: explicit ordering of initcalls Herbert Xu
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=20220124202951.28579-2-linux@dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=Jason@zx2c4.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpm@selenic.com \
/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
all inboxes | Powered by JetHome®