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]
Message-ID: <3a8d5d2d-d54f-cf18-0c93-dbe8cd91ed12@infradead.org>
Date:   Wed, 15 Jan 2020 16:11:40 -0800
From:   Randy Dunlap <rdunlap@...radead.org>
To:     Stephan Müller <smueller@...onox.de>,
        Arnd Bergmann <arnd@...db.de>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-crypto@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        linux-api@...r.kernel.org,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        "Alexander E. Patrakov" <patrakov@...il.com>,
        "Ahmed S. Darwish" <darwish.07@...il.com>,
        "Theodore Y. Ts'o" <tytso@....edu>, Willy Tarreau <w@....eu>,
        Matthew Garrett <mjg59@...f.ucam.org>,
        Vito Caputo <vcaputo@...garu.com>,
        Andreas Dilger <adilger.kernel@...ger.ca>,
        Jan Kara <jack@...e.cz>, Ray Strode <rstrode@...hat.com>,
        William Jon McCann <mccann@....edu>,
        zhangjs <zachary@...shancloud.com>,
        Andy Lutomirski <luto@...nel.org>,
        Florian Weimer <fweimer@...hat.com>,
        Lennart Poettering <mzxreary@...inter.de>,
        Nicolai Stange <nstange@...e.de>,
        "Peter, Matthias" <matthias.peter@....bund.de>,
        Marcelo Henrique Cerri <marcelo.cerri@...onical.com>,
        Roman Drahtmueller <draht@...altsekun.de>,
        Neil Horman <nhorman@...hat.com>,
        Julia Lawall <julia.lawall@...ia.fr>,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH v28 01/12] Linux Random Number Generator

Hi,

On 1/15/20 2:31 AM, Stephan Müller wrote:

> CC: "Eric W. Biederman" <ebiederm@...ssion.com>
> CC: "Alexander E. Patrakov" <patrakov@...il.com>
> CC: "Ahmed S. Darwish" <darwish.07@...il.com>
> CC: "Theodore Y. Ts'o" <tytso@....edu>
> CC: Willy Tarreau <w@....eu>
> CC: Matthew Garrett <mjg59@...f.ucam.org>
> CC: Vito Caputo <vcaputo@...garu.com>
> CC: Andreas Dilger <adilger.kernel@...ger.ca>
> CC: Jan Kara <jack@...e.cz>
> CC: Ray Strode <rstrode@...hat.com>
> CC: William Jon McCann <mccann@....edu>
> CC: zhangjs <zachary@...shancloud.com>
> CC: Andy Lutomirski <luto@...nel.org>
> CC: Florian Weimer <fweimer@...hat.com>
> CC: Lennart Poettering <mzxreary@...inter.de>
> CC: Nicolai Stange <nstange@...e.de>
> Mathematical aspects Reviewed-by: "Peter, Matthias" <matthias.peter@....bund.de>
> Reviewed-by: Marcelo Henrique Cerri <marcelo.cerri@...onical.com>
> Reviewed-by: Roman Drahtmueller <draht@...altsekun.de>
> Tested-by: Roman Drahtmüller <draht@...altsekun.de>
> Tested-by: Marcelo Henrique Cerri <marcelo.cerri@...onical.com>
> Tested-by: Neil Horman <nhorman@...hat.com>
> Signed-off-by: Stephan Mueller <smueller@...onox.de>
> ---
>  MAINTAINERS                         |   7 +
>  drivers/char/Kconfig                |   2 +
>  drivers/char/Makefile               |   9 +-
>  drivers/char/lrng/Kconfig           |  67 +++
>  drivers/char/lrng/Makefile          |   9 +
>  drivers/char/lrng/lrng_archrandom.c |  94 ++++
>  drivers/char/lrng/lrng_aux.c        | 148 +++++++
>  drivers/char/lrng/lrng_chacha20.c   | 265 ++++++++++++
>  drivers/char/lrng/lrng_chacha20.h   |  25 ++
>  drivers/char/lrng/lrng_drng.c       | 400 +++++++++++++++++
>  drivers/char/lrng/lrng_interfaces.c | 638 ++++++++++++++++++++++++++++
>  drivers/char/lrng/lrng_internal.h   | 296 +++++++++++++
>  drivers/char/lrng/lrng_lfsr.h       | 152 +++++++
>  drivers/char/lrng/lrng_pool.c       | 588 +++++++++++++++++++++++++
>  drivers/char/lrng/lrng_sw_noise.c   | 102 +++++
>  drivers/char/lrng/lrng_sw_noise.h   |  57 +++
>  include/linux/lrng.h                |  63 +++
>  17 files changed, 2921 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/char/lrng/Kconfig
>  create mode 100644 drivers/char/lrng/Makefile
>  create mode 100644 drivers/char/lrng/lrng_archrandom.c
>  create mode 100644 drivers/char/lrng/lrng_aux.c
>  create mode 100644 drivers/char/lrng/lrng_chacha20.c
>  create mode 100644 drivers/char/lrng/lrng_chacha20.h
>  create mode 100644 drivers/char/lrng/lrng_drng.c
>  create mode 100644 drivers/char/lrng/lrng_interfaces.c
>  create mode 100644 drivers/char/lrng/lrng_internal.h
>  create mode 100644 drivers/char/lrng/lrng_lfsr.h
>  create mode 100644 drivers/char/lrng/lrng_pool.c
>  create mode 100644 drivers/char/lrng/lrng_sw_noise.c
>  create mode 100644 drivers/char/lrng/lrng_sw_noise.h
>  create mode 100644 include/linux/lrng.h
> 

> diff --git a/drivers/char/lrng/Kconfig b/drivers/char/lrng/Kconfig
> new file mode 100644
> index 000000000000..56f13efd3592
> --- /dev/null
> +++ b/drivers/char/lrng/Kconfig
> @@ -0,0 +1,67 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Linux Random Number Generator configuration
> +#
> +
> +menuconfig LRNG
> +	bool "Linux Random Number Generator"

This should probably depend on CRYPTO and/or some other CRYPTO_xxx symbols.
Or (worst case) select them.  :(

This message (when CONFIG_CRYPTO is disabled and no crypto facilities are enabled)
should be avoidable when the correct Kconfig entries are used:

../drivers/char/lrng/lrng_drbg.c:38:2: error: #error "Unknown DRBG in use"
 #error "Unknown DRBG in use"


> +	help
> +	  The Linux Random Number Generator (LRNG) is the replacement
> +	  of the existing /dev/random provided with drivers/char/random.c.
> +	  It generates entropy from different noise sources and
> +	  delivers significant entropy during boot.
> +
> +if LRNG
> +
> +choice
> +	prompt "LRNG Entropy Pool Size"
> +	default LRNG_POOL_SIZE_4096
> +	help
> +	  Select the size of the LRNG entropy pool. The size of the
> +	  entropy pool is relevant for the amount of entropy that
> +	  the LRNG can maintain as a maximum. The larger the size
> +	  of the entropy pool is the more entropy can be maintained
> +	  but the less often older entropic values are overwritten
> +	  with new entropy.
> +
> +	config LRNG_POOL_SIZE_512
> +		bool "512 bits"
> +
> +	config LRNG_POOL_SIZE_1024
> +		bool "1024 bits"
> +
> +	config LRNG_POOL_SIZE_2048
> +		bool "2048 bits"
> +
> +	config LRNG_POOL_SIZE_4096
> +		bool "4096 bits (default)"
> +
> +	config LRNG_POOL_SIZE_8192
> +		bool "8192 bits"
> +
> +	config LRNG_POOL_SIZE_16384
> +		bool "16384 bits"
> +
> +	config LRNG_POOL_SIZE_32768
> +		bool "32768 bits"
> +
> +	config LRNG_POOL_SIZE_65536
> +		bool "65536 bits"
> +
> +	config LRNG_POOL_SIZE_131072
> +		bool "131072 bits"
> +endchoice
> +
> +config LRNG_POOL_SIZE
> +	int
> +	default 0 if LRNG_POOL_SIZE_512
> +	default 1 if LRNG_POOL_SIZE_1024
> +	default 2 if LRNG_POOL_SIZE_2048
> +	default 3 if LRNG_POOL_SIZE_4096
> +	default 4 if LRNG_POOL_SIZE_8192
> +	default 5 if LRNG_POOL_SIZE_16384
> +	default 6 if LRNG_POOL_SIZE_32768
> +	default 7 if LRNG_POOL_SIZE_65536
> +	default 8 if LRNG_POOL_SIZE_131072
> +
> +endif # LRNG

> diff --git a/drivers/char/lrng/lrng_archrandom.c b/drivers/char/lrng/lrng_archrandom.c
> new file mode 100644
> index 000000000000..eeba708d025f
> --- /dev/null
> +++ b/drivers/char/lrng/lrng_archrandom.c
> @@ -0,0 +1,94 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
> +/*
> + * LRNG Fast Noise Source: CPU-based noise source
> + *
> + * Copyright (C) 2016 - 2020, Stephan Mueller <smueller@...onox.de>
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/random.h>
> +
> +#include "lrng_internal.h"
> +
> +/*
> + * Estimated entropy of data is a 32th of LRNG_DRNG_SECURITY_STRENGTH_BITS.
> + * As we have no ability to review the implementation of those noise sources,
> + * it is prudent to have a conservative estimate here.
> + */
> +#define LRNG_ARCHRANDOM_DEFAULT_STRENGTH (LRNG_DRNG_SECURITY_STRENGTH_BITS>>5)
> +#define LRNG_ARCHRANDOM_TRUST_CPU_STRENGTH LRNG_DRNG_SECURITY_STRENGTH_BITS
> +#ifdef CONFIG_RANDOM_TRUST_CPU
> +static u32 archrandom = LRNG_ARCHRANDOM_TRUST_CPU_STRENGTH;
> +#else
> +static u32 archrandom = LRNG_ARCHRANDOM_DEFAULT_STRENGTH;
> +#endif
> +module_param(archrandom, uint, 0644);
> +MODULE_PARM_DESC(archrandom, "Entropy in bits of 256 data bits from CPU noise "
> +			     "source (e.g. RDRAND)");

Please put the string on one line like several other MODULE_PARM_DESC() are done:

+MODULE_PARM_DESC(archrandom,
+		"Entropy in bits of 256 data bits from CPU noise source (e.g. RDRAND)");


With CONFIG_CRYPTO disabled, these warnings happen:

WARNING: unmet direct dependencies detected for CRYPTO_DRBG_MENU
  Depends on [n]: CRYPTO [=n]
  Selected by [m]:
  - LRNG_DRBG [=m] && LRNG [=y] && LRNG_DRNG_SWITCH [=y]

WARNING: unmet direct dependencies detected for CRYPTO_RNG
  Depends on [n]: CRYPTO [=n]
  Selected by [m]:
  - LRNG_KCAPI [=m] && LRNG [=y] && LRNG_DRNG_SWITCH [=y]

../drivers/char/lrng/lrng_drbg.c: In function ‘lrng_hash_name’:
../drivers/char/lrng/lrng_drbg.c:225:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
../drivers/char/lrng/lrng_drbg.c: In function ‘lrng_drbg_name’:
../drivers/char/lrng/lrng_drbg.c:220:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

and build errors happen also, which can be prevented with Kconfig fixes.

-- 
~Randy
Reported-by: Randy Dunlap <rdunlap@...radead.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ