lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 08 May 2022 05:57:18 -0700
From:   Joe Perches <joe@...ches.com>
To:     "Jason A. Donenfeld" <Jason@...c4.com>,
        linux-kernel@...r.kernel.org
Cc:     Dominik Brodowski <linux@...inikbrodowski.net>
Subject: Re: [PATCH] random: use symbolic constants for crng_init states

On Sun, 2022-05-08 at 13:26 +0200, Jason A. Donenfeld wrote:
> crng_init represents a state machine, with three states, and various
> rules for transitions. For the longest time, we've been managing these
> with "0", "1", and "2", and expecting people to figure it out. To make
> the code more obvious, replace these with proper enum values
> representing the transition, and then redocument what each of these
> states mean.

good idea

> diff --git a/drivers/char/random.c b/drivers/char/random.c
[]
> @@ -72,16 +72,16 @@
[]
> -/* Various types of waiters for crng_init->2 transition. */
> +static enum {
> +	CRNG_EMPTY = 0, /* Little to no entropy collected */
> +	CRNG_EARLY = 1, /* At least POOL_EARLY_BITS collected */
> +	CRNG_READY = 2  /* Fully iniitalized with POOL_READY_BITS collected */

typo: initialized

>  enum {
>  	POOL_BITS = BLAKE2S_HASH_SIZE * 8,
> -	POOL_INIT_BITS = POOL_BITS, /* No point in settling for less. */
> -	POOL_FAST_INIT_BITS = POOL_INIT_BITS / 2
> +	POOL_READY_BITS = POOL_BITS, /* When crng_init->CRNG_READY */
> +	POOL_EARLY_BITS = POOL_READY_BITS / 2 /* When crng_init->CRNG_EARLY */

Seems odd to use a divisor with an enum


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ