# Re: \[PATCH v28 11/12\] LRNG - add interface for gathering of raw entropy

- From: Randy Dunlap \<rdunlap@infradead.org\>
- Date: 2020-01-16 00:18:53 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2020/01/5832138
- Thread: https://ratatoskr.run/linux-crypto/2019/11/5773044/t/2.md

```text
On 1/15/20 2:35 AM, Stephan Müller wrote:

> 
> CC: "Eric W. Biederman" <redacted>
> CC: "Alexander E. Patrakov" <redacted>
> CC: "Ahmed S. Darwish" <redacted>
> CC: "Theodore Y. Ts'o" <tytso@mit.edu>
> CC: Willy Tarreau <w@1wt.eu>
> CC: Matthew Garrett <mjg59@srcf.ucam.org>
> CC: Vito Caputo <redacted>
> CC: Andreas Dilger <adilger.kernel@dilger.ca>
> CC: Jan Kara <jack@suse.cz>
> CC: Ray Strode <redacted>
> CC: William Jon McCann <redacted>
> CC: zhangjs <redacted>
> CC: Andy Lutomirski <luto@kernel.org>
> CC: Florian Weimer <redacted>
> CC: Lennart Poettering <redacted>
> CC: Nicolai Stange <redacted>
> Reviewed-by: Roman Drahtmueller <redacted>
> Tested-by: Roman Drahtmüller <redacted>
> Tested-by: Marcelo Henrique Cerri <redacted>
> Tested-by: Neil Horman <redacted>
> Signed-off-by: Stephan Mueller <redacted>
> ---
>  drivers/char/lrng/Kconfig        |  16 ++
>  drivers/char/lrng/Makefile       |   1 +
>  drivers/char/lrng/lrng_testing.c | 271 +++++++++++++++++++++++++++++++
>  3 files changed, 288 insertions(+)
>  create mode 100644 drivers/char/lrng/lrng_testing.c
> 

> diff --git a/drivers/char/lrng/lrng_testing.c b/drivers/char/lrng/lrng_testing.c
> new file mode 100644
> index 000000000000..0e287eccd622
> --- /dev/null
> +++ b/drivers/char/lrng/lrng_testing.c
> @@ -0,0 +1,271 @@
> +// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
> +/*
> + * Linux Random Number Generator (LRNG) Raw entropy collection tool
> + *
> + * Copyright (C) 2019 - 2020, Stephan Mueller [ref]
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/atomic.h>
> +#include <linux/bug.h>
> +#include <linux/debugfs.h>
> +#include <linux/module.h>
> +#include <linux/sched.h>
> +#include <linux/sched/signal.h>
> +#include <linux/slab.h>
> +#include <linux/string.h>
> +#include <linux/types.h>
> +#include <linux/uaccess.h>
> +#include <linux/workqueue.h>
> +#include <asm/errno.h>
> +
> +#include "lrng_internal.h"
> +
> +#define LRNG_TESTING_RINGBUFFER_SIZE	1024
> +#define LRNG_TESTING_RINGBUFFER_MASK	(LRNG_TESTING_RINGBUFFER_SIZE - 1)
> +
> +static u32 lrng_testing_rb[LRNG_TESTING_RINGBUFFER_SIZE];
> +static u32 lrng_rb_reader = 0;
> +static u32 lrng_rb_writer = 0;
> +static atomic_t lrng_testing_enabled = ATOMIC_INIT(0);
> +
> +static DECLARE_WAIT_QUEUE_HEAD(lrng_raw_read_wait);
> +static DEFINE_SPINLOCK(lrng_raw_lock);
> +
> +/*
> + * 0 ==> No boot test, gathering of runtime data allowed
> + * 1 ==> Boot test enabled and ready for collecting data, gathering runtime
> + *	 data is disabled
> + * 2 ==> Boot test completed and disabled, gathering of runtime data is
> + *	 disabled
> + */
> +static u32 boot_test = 0;
> +module_param(boot_test, uint, 0644);
> +MODULE_PARM_DESC(boot_test, "Enable gathering boot time entropy of the first"
> +			    " entropy events");

One line for the string, please.


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