[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHmME9rH1cHwPhf-mSyD7sas3rBHhYPDd1CvG+68Vw1piRR6QA@mail.gmail.com>
Date: Fri, 31 Dec 2021 12:31:23 +0100
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: Dominik Brodowski <linux@...inikbrodowski.net>
Cc: LKML <linux-kernel@...r.kernel.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Linux Crypto Mailing List <linux-crypto@...r.kernel.org>
Subject: Re: [PATCH v2] random: early initialization of ChaCha constants
Thanks, looks good. I tried briefly to break it with the following
assertion thing, but didn't come up with any hits, so it looks like
we're all set. Prior to applying this patch, I found the easiest way
of triggering the below crash was by enabling
CONFIG_SLAB_FREELIST_RANDOM.
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 4de0feb69781..0d9ac045943f 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1035,6 +1035,10 @@ static void _extract_crng(struct crng_state *crng,
spin_lock_irqsave(&crng->lock, flags);
if (arch_get_random_long(&v))
crng->state[14] ^= v;
+ BUG_ON(crng->state[0] != CHACHA_CONSTANT_EXPA);
+ BUG_ON(crng->state[1] != CHACHA_CONSTANT_ND_3);
+ BUG_ON(crng->state[2] != CHACHA_CONSTANT_2_BY);
+ BUG_ON(crng->state[3] != CHACHA_CONSTANT_TE_K);
chacha20_block(&crng->state[0], out);
if (crng->state[12] == 0)
crng->state[13]++;
Powered by blists - more mailing lists