Skip to contentSkip to conversation

random: maintenance administrivia

PATCH Superseded Jason A. Donenfeld 4 participants 19 messages Feb 10, 2022 – Feb 21, 2022

Subsystems (6)
lore
Share & tools
lore

Jason A. Donenfeld

author maintainer
#0 lore raw

cover random: maintenance administrivia

These patches aren't very interesting: removing unused debugging code and switching to SPDX. I'm not aware of any special ritual being required to SPDXify a file aside from just doing it, but please correct me if I'm wrong; none of the copyright info changes.

Cc Greg Kroah-Hartman <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>

Jason A. Donenfeld (3):
random: remove ifdef'd out interrupt bench
random: remove unused tracepoints
random: add proper SPDX header

 drivers/char/random.c         | 110 +-----------------
 include/linux/random.h        |   5 -
 include/trace/events/random.h | 206 ----------------------------------
 lib/random32.c                |   2 -
 4 files changed, 5 insertions(+), 318 deletions(-)
 delete mode 100644 include/trace/events/random.h
Signature · 1 line
2.35.0
author maintainer
#1 lore raw

PATCH 1/3 random: remove ifdef'd out interrupt bench

With tools like kbench9000 giving more finegrained responses, and this basically never having been used ever since it was initially added, let's just get rid of this. There *is* still work to be done on the interrupt handler, but this really isn't the way it's being developed.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c | 40 ----------------------------------------
 1 file changed, 40 deletions(-)
drivers/char/random.c +0 -40
index 57d36f13e3a6..cf535596d1bc 100644
@@ -240,8 +240,6 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/random.h>
 
-/* #define ADD_INTERRUPT_BENCH */
-
 enum {
 	POOL_BITS = BLAKE2S_HASH_SIZE * 8,
 	POOL_MIN_BITS = POOL_BITS /* No point in settling for less. */
@@ -806,27 +804,6 @@ EXPORT_SYMBOL_GPL(add_input_randomness);
 
 static DEFINE_PER_CPU(struct fast_pool, irq_randomness);
 
-#ifdef ADD_INTERRUPT_BENCH
-static unsigned long avg_cycles, avg_deviation;
-
-#define AVG_SHIFT 8 /* Exponential average factor k=1/256 */
-#define FIXED_1_2 (1 << (AVG_SHIFT - 1))
-
-static void add_interrupt_bench(cycles_t start)
-{
-	long delta = random_get_entropy() - start;
-
-	/* Use a weighted moving average */
-	delta = delta - ((avg_cycles + FIXED_1_2) >> AVG_SHIFT);
-	avg_cycles += delta;
-	/* And average deviation */
-	delta = abs(delta) - ((avg_deviation + FIXED_1_2) >> AVG_SHIFT);
-	avg_deviation += delta;
-}
-#else
-#define add_interrupt_bench(x)
-#endif
-
 static u32 get_reg(struct fast_pool *f, struct pt_regs *regs)
 {
 	u32 *ptr = (u32 *)regs;
@@ -885,7 +862,6 @@ void add_interrupt_randomness(int irq)
 		(sizeof(ip) > 4) ? ip >> 32 : get_reg(fast_pool, regs);
 
 	fast_mix(fast_pool);
-	add_interrupt_bench(cycles);
 	new_count = ++fast_pool->count;
 
 	if (unlikely(crng_init == 0)) {
@@ -1595,22 +1571,6 @@ static struct ctl_table random_table[] = {
 		.mode		= 0444,
 		.proc_handler	= proc_do_uuid,
 	},
-#ifdef ADD_INTERRUPT_BENCH
-	{
-		.procname	= "add_interrupt_avg_cycles",
-		.data		= &avg_cycles,
-		.maxlen		= sizeof(avg_cycles),
-		.mode		= 0444,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
-	{
-		.procname	= "add_interrupt_avg_deviation",
-		.data		= &avg_deviation,
-		.maxlen		= sizeof(avg_deviation),
-		.mode		= 0444,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
-#endif
 	{ }
 };
 
Signature · 1 line
2.35.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] random: remove ifdef'd out interrupt bench

Am Thu, Feb 10, 2022 at 04:50:10PM +0100 schrieb Jason A. Donenfeld:

Quoted 8 lines

With tools like kbench9000 giving more finegrained responses, and this basically never having been used ever since it was initially added, let's just get rid of this. There *is* still work to be done on the interrupt handler, but this really isn't the way it's being developed.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>

Thanks,
Dominik

Reviewed-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] random: remove ifdef'd out interrupt bench

In reply to Jason A. Donenfeld
Quoted 11 lines · Jason A. Donenfeld

With tools like kbench9000 giving more finegrained responses, and this basically never having been used ever since it was initially added, let's just get rid of this. There *is* still work to be done on the interrupt handler, but this really isn't the way it's being developed.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c | 40 ----------------------------------------
 1 file changed, 40 deletions(-)

- Eric

#4 lore raw

Re: [PATCH 1/3] random: remove ifdef'd out interrupt bench

Quoted 13 lines · Eric Biggers
Quoted 11 lines · Jason A. Donenfeld

With tools like kbench9000 giving more finegrained responses, and this basically never having been used ever since it was initially added, let's just get rid of this. There *is* still work to be done on the interrupt handler, but this really isn't the way it's being developed.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c | 40 ----------------------------------------
 1 file changed, 40 deletions(-)
Quoted 3 lines

- Eric

Actually one comment: there is a reference to ADD_INTERRUPT_BENCH in Documentation/admin-guide/sysctl/kernel.rst that needs to be removed.

- Eric

author maintainer
#5 lore raw

Re: [PATCH 1/3] random: remove ifdef'd out interrupt bench

Quoted 15 lines · Eric Biggers
Quoted 13 lines · Eric Biggers
Quoted 11 lines · Jason A. Donenfeld

With tools like kbench9000 giving more finegrained responses, and this basically never having been used ever since it was initially added, let's just get rid of this. There *is* still work to be done on the interrupt handler, but this really isn't the way it's being developed.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c | 40 ----------------------------------------
 1 file changed, 40 deletions(-)
Quoted 6 lines
Quoted 3 lines

- Eric

Actually one comment: there is a reference to ADD_INTERRUPT_BENCH in Documentation/admin-guide/sysctl/kernel.rst that needs to be removed.

Thanks, will do.

author maintainer
#6 lore raw

PATCH v2 1/1 random: remove ifdef'd out interrupt bench

With tools like kbench9000 giving more finegrained responses, and this basically never having been used ever since it was initially added, let's just get rid of this. There *is* still work to be done on the interrupt handler, but this really isn't the way it's being developed.

---
v2 updates kernel.rst.

 Documentation/admin-guide/sysctl/kernel.rst |  9 -----
 drivers/char/random.c                       | 40 ---------------------
 2 files changed, 49 deletions(-)
Documentation/admin-guide/sysctl/kernel.rst +0 -9
index d3c6d9a501a9..5dd660aac0ae 100644
@@ -1041,15 +1041,6 @@ This is a directory, with the following entries:
   are woken up. This file is writable for compatibility purposes, but
   writing to it has no effect on any RNG behavior.
 
-If ``drivers/char/random.c`` is built with ``ADD_INTERRUPT_BENCH``
-defined, these additional entries are present:
-
-* ``add_interrupt_avg_cycles``: the average number of cycles between
-  interrupts used to feed the pool;
-
-* ``add_interrupt_avg_deviation``: the standard deviation seen on the
-  number of cycles between interrupts used to feed the pool.
-
 
 randomize_va_space
 ==================
drivers/char/random.c +0 -40
index c27ebf707380..35c440a0d83c 100644
@@ -240,8 +240,6 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/random.h>
 
-/* #define ADD_INTERRUPT_BENCH */
-
 enum {
 	POOL_BITS = BLAKE2S_HASH_SIZE * 8,
 	POOL_MIN_BITS = POOL_BITS /* No point in settling for less. */
@@ -808,27 +806,6 @@ EXPORT_SYMBOL_GPL(add_input_randomness);
 
 static DEFINE_PER_CPU(struct fast_pool, irq_randomness);
 
-#ifdef ADD_INTERRUPT_BENCH
-static unsigned long avg_cycles, avg_deviation;
-
-#define AVG_SHIFT 8 /* Exponential average factor k=1/256 */
-#define FIXED_1_2 (1 << (AVG_SHIFT - 1))
-
-static void add_interrupt_bench(cycles_t start)
-{
-	long delta = random_get_entropy() - start;
-
-	/* Use a weighted moving average */
-	delta = delta - ((avg_cycles + FIXED_1_2) >> AVG_SHIFT);
-	avg_cycles += delta;
-	/* And average deviation */
-	delta = abs(delta) - ((avg_deviation + FIXED_1_2) >> AVG_SHIFT);
-	avg_deviation += delta;
-}
-#else
-#define add_interrupt_bench(x)
-#endif
-
 static u32 get_reg(struct fast_pool *f, struct pt_regs *regs)
 {
 	u32 *ptr = (u32 *)regs;
@@ -865,7 +842,6 @@ void add_interrupt_randomness(int irq)
 		(sizeof(ip) > 4) ? ip >> 32 : get_reg(fast_pool, regs);
 
 	fast_mix(fast_pool);
-	add_interrupt_bench(cycles);
 
 	if (unlikely(crng_init == 0)) {
 		if (fast_pool->count >= 64 &&
@@ -1574,22 +1550,6 @@ static struct ctl_table random_table[] = {
 		.mode		= 0444,
 		.proc_handler	= proc_do_uuid,
 	},
-#ifdef ADD_INTERRUPT_BENCH
-	{
-		.procname	= "add_interrupt_avg_cycles",
-		.data		= &avg_cycles,
-		.maxlen		= sizeof(avg_cycles),
-		.mode		= 0444,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
-	{
-		.procname	= "add_interrupt_avg_deviation",
-		.data		= &avg_deviation,
-		.maxlen		= sizeof(avg_deviation),
-		.mode		= 0444,
-		.proc_handler	= proc_doulongvec_minmax,
-	},
-#endif
 	{ }
 };
 
Signature · 1 line
2.35.1
author maintainer
#7 lore raw

PATCH 2/3 random: remove unused tracepoints

In reply to Jason A. Donenfeld

These explicit tracepoints aren't really used and show sign of aging. It's work to keep these up to date, and before I attempted to keep them up to date, they weren't up to date, which indicates that they're not really used. These days there are better ways of introspecting anyway.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c         |  30 +----
 include/trace/events/random.h | 206 ----------------------------------
 lib/random32.c                |   2 -
 3 files changed, 3 insertions(+), 235 deletions(-)
 delete mode 100644 include/trace/events/random.h
drivers/char/random.c +3 -27
index cf535596d1bc..30a3c0717e3e 100644
@@ -237,9 +237,6 @@
 #include <asm/irq_regs.h>
 #include <asm/io.h>
 
-#define CREATE_TRACE_POINTS
-#include <trace/events/random.h>
-
 enum {
 	POOL_BITS = BLAKE2S_HASH_SIZE * 8,
 	POOL_MIN_BITS = POOL_BITS /* No point in settling for less. */
@@ -315,7 +312,6 @@ static void mix_pool_bytes(const void *in, size_t nbytes)
 {
 	unsigned long flags;
 
-	trace_mix_pool_bytes(nbytes, _RET_IP_);
 	spin_lock_irqsave(&input_pool.lock, flags);
 	_mix_pool_bytes(in, nbytes);
 	spin_unlock_irqrestore(&input_pool.lock, flags);
@@ -390,8 +386,6 @@ static void credit_entropy_bits(size_t nbits)
 		entropy_count = min_t(unsigned int, POOL_BITS, orig + add);
 	} while (cmpxchg(&input_pool.entropy_count, orig, entropy_count) != orig);
 
-	trace_credit_entropy_bits(nbits, entropy_count, _RET_IP_);
-
 	if (crng_init < 2 && entropy_count >= POOL_MIN_BITS)
 		crng_reseed();
 }
@@ -719,7 +713,6 @@ void add_device_randomness(const void *buf, size_t size)
 	if (!crng_ready() && size)
 		crng_slow_load(buf, size);
 
-	trace_add_device_randomness(size, _RET_IP_);
 	spin_lock_irqsave(&input_pool.lock, flags);
 	_mix_pool_bytes(buf, size);
 	_mix_pool_bytes(&time, sizeof(time));
@@ -798,7 +791,6 @@ void add_input_randomness(unsigned int type, unsigned int code,
 	last_value = value;
 	add_timer_randomness(&input_timer_state,
 			     (type << 4) ^ code ^ (code >> 4) ^ value);
-	trace_add_input_randomness(input_pool.entropy_count);
 }
 EXPORT_SYMBOL_GPL(add_input_randomness);
 
@@ -900,7 +892,6 @@ void add_disk_randomness(struct gendisk *disk)
 		return;
 	/* first major is 1, so we get >= 0x200 here */
 	add_timer_randomness(disk->random, 0x100 + disk_devt(disk));
-	trace_add_disk_randomness(disk_devt(disk), input_pool.entropy_count);
 }
 EXPORT_SYMBOL_GPL(add_disk_randomness);
 #endif
@@ -925,8 +916,6 @@ static void extract_entropy(void *buf, size_t nbytes)
 	} block;
 	size_t i;
 
-	trace_extract_entropy(nbytes, input_pool.entropy_count);
-
 	for (i = 0; i < ARRAY_SIZE(block.rdseed); ++i) {
 		if (!arch_get_random_seed_long(&block.rdseed[i]) &&
 		    !arch_get_random_long(&block.rdseed[i]))
@@ -998,8 +987,6 @@ static void _get_random_bytes(void *buf, size_t nbytes)
 	u8 tmp[CHACHA_BLOCK_SIZE];
 	size_t len;
 
-	trace_get_random_bytes(nbytes, _RET_IP_);
-
 	if (!nbytes)
 		return;
 
@@ -1197,7 +1184,6 @@ size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes)
 	size_t left = nbytes;
 	u8 *p = buf;
 
-	trace_get_random_bytes_arch(left, _RET_IP_);
 	while (left) {
 		unsigned long v;
 		size_t chunk = min_t(size_t, left, sizeof(unsigned long));
@@ -1281,16 +1267,6 @@ void rand_initialize_disk(struct gendisk *disk)
 }
 #endif
 
-static ssize_t urandom_read_nowarn(struct file *file, char __user *buf,
-				   size_t nbytes, loff_t *ppos)
-{
-	ssize_t ret;
-
-	ret = get_random_bytes_user(buf, nbytes);
-	trace_urandom_read(nbytes, input_pool.entropy_count);
-	return ret;
-}
-
 static ssize_t urandom_read(struct file *file, char __user *buf, size_t nbytes,
 			    loff_t *ppos)
 {
@@ -1303,7 +1279,7 @@ static ssize_t urandom_read(struct file *file, char __user *buf, size_t nbytes,
 				  current->comm, nbytes);
 	}
 
-	return urandom_read_nowarn(file, buf, nbytes, ppos);
+	return get_random_bytes_user(buf, nbytes);
 }
 
 static ssize_t random_read(struct file *file, char __user *buf, size_t nbytes,
@@ -1314,7 +1290,7 @@ static ssize_t random_read(struct file *file, char __user *buf, size_t nbytes,
 	ret = wait_for_random_bytes();
 	if (ret != 0)
 		return ret;
-	return urandom_read_nowarn(file, buf, nbytes, ppos);
+	return get_random_bytes_user(buf, nbytes);
 }
 
 static __poll_t random_poll(struct file *file, poll_table *wait)
@@ -1475,7 +1451,7 @@ SYSCALL_DEFINE3(getrandom, char __user *, buf, size_t, count, unsigned int,
 		if (unlikely(ret))
 			return ret;
 	}
-	return urandom_read_nowarn(NULL, buf, count, NULL);
+	return get_random_bytes_user(buf, count);
 }
 
 /********************************************************************
include/trace/events/random.h deleted +0 -206

206 lines not on this page · raw message

lib/random32.c +0 -2
index a57a0e18819d..3c19820796d0 100644
@@ -41,7 +41,6 @@
 #include <linux/bitops.h>
 #include <linux/slab.h>
 #include <asm/unaligned.h>
-#include <trace/events/random.h>
 
 /**
  *	prandom_u32_state - seeded pseudo-random number generator.
@@ -387,7 +386,6 @@ u32 prandom_u32(void)
 	struct siprand_state *state = get_cpu_ptr(&net_rand_state);
 	u32 res = siprand_u32(state);
 
-	trace_prandom_u32(res);
 	put_cpu_ptr(&net_rand_state);
 	return res;
 }
Signature · 1 line
2.35.0
Reviewed-by on v1 2/3
#8 lore raw

Re: [PATCH 2/3] random: remove unused tracepoints

Am Thu, Feb 10, 2022 at 04:50:11PM +0100 schrieb Jason A. Donenfeld:

Quoted 8 lines

These explicit tracepoints aren't really used and show sign of aging. It's work to keep these up to date, and before I attempted to keep them up to date, they weren't up to date, which indicates that they're not really used. These days there are better ways of introspecting anyway.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>

Thanks,
Dominik

Reviewed-by on v1 2/3
#9 lore raw

Re: [PATCH 2/3] random: remove unused tracepoints

In reply to Jason A. Donenfeld
Quoted 8 lines · Jason A. Donenfeld

These explicit tracepoints aren't really used and show sign of aging. It's work to keep these up to date, and before I attempted to keep them up to date, they weren't up to date, which indicates that they're not really used. These days there are better ways of introspecting anyway.

Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
Quoted 6 lines
---
 drivers/char/random.c         |  30 +----
 include/trace/events/random.h | 206 ----------------------------------
 lib/random32.c                |   2 -
 3 files changed, 3 insertions(+), 235 deletions(-)
 delete mode 100644 include/trace/events/random.h

- Eric

author maintainer
#10 lore raw

PATCH 3/3 random: add proper SPDX header

In reply to Jason A. Donenfeld

Somehow this file missed the SPDXification efforts several years ago.

Cc Greg Kroah-Hartman <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
---
 drivers/char/random.c  | 40 ++--------------------------------------
 include/linux/random.h |  5 -----
 2 files changed, 2 insertions(+), 43 deletions(-)
drivers/char/random.c +2 -38
index 30a3c0717e3e..77131f7b0f06 100644
@@ -1,44 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
- * random.c -- A strong random number generator
- *
  * Copyright (C) 2017-2022 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
- *
  * Copyright Matt Mackall <[email protected]>, 2003, 2004, 2005
- *
- * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All
- * rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, and the entire permission notice in its entirety,
- *    including the disclaimer of warranties.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions.  (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
- * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
+ * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All rights reserved.
  */
 
 /*
include/linux/random.h +0 -5
index e92efb39779c..1a6861aa1277 100644
@@ -1,9 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/*
- * include/linux/random.h
- *
- * Include file for the random number generator.
- */
 #ifndef _LINUX_RANDOM_H
 #define _LINUX_RANDOM_H
 
Signature · 1 line
2.35.0
author maintainer
#11 lore raw

Re: [PATCH 3/3] random: add proper SPDX header

Somebody pointed out to me online that the original license here was closer to BSD. I'll resubmit this, and also get linux-spdx on the thread, as we should be careful about this.

Jason

author maintainer
#12 lore raw

PATCH v2 1/1 random: add proper SPDX header

Somehow this file missed the SPDXification efforts several years ago. Convert the current license into "(GPL-2.0-or-later OR BSD-3-Clause)".

Cc Thomas Gleixner <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>

---
Hi SPDX List,

I think I got this conversion right, but I would certainly appreciate a review on this from somebody with more legal expertise than me.

Thanks,
Jason

 drivers/char/random.c  | 40 ++--------------------------------------
 include/linux/random.h |  5 -----
 2 files changed, 2 insertions(+), 43 deletions(-)
drivers/char/random.c +2 -38
index 324574b03120..a2bbae5a693d 100644
@@ -1,44 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
 /*
- * random.c -- A strong random number generator
- *
  * Copyright (C) 2017-2022 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
- *
  * Copyright Matt Mackall <[email protected]>, 2003, 2004, 2005
- *
- * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All
- * rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, and the entire permission notice in its entirety,
- *    including the disclaimer of warranties.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions.  (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
- * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
+ * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All rights reserved.
  */
 
 /*
include/linux/random.h +0 -5
index e92efb39779c..1a6861aa1277 100644
@@ -1,9 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/*
- * include/linux/random.h
- *
- * Include file for the random number generator.
- */
 #ifndef _LINUX_RANDOM_H
 #define _LINUX_RANDOM_H
 
Signature · 1 line
2.35.0
#13 lore raw

Re: [PATCH v2] random: add proper SPDX header

Quoted 1 line · Jason A. Donenfeld

Somehow this file missed the SPDXification efforts several years ago.

That is because it required manual review.

Quoted 7 lines

Convert the current license into "(GPL-2.0-or-later OR BSD-3-Clause)".

Cc Thomas Gleixner <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
Quoted 5 lines

---
Hi SPDX List,

I think I got this conversion right, but I would certainly appreciate a review on this from somebody with more legal expertise than me.

Where did the "or later" come from? I don't see that in the original text.

Quoted 26 lines

Thanks,
Jason

 drivers/char/random.c  | 40 ++--------------------------------------
 include/linux/random.h |  5 -----
 2 files changed, 2 insertions(+), 43 deletions(-)
drivers/char/random.c +1 -9
index 324574b03120..a2bbae5a693d 100644
@@ -1,44 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-3-Clause)
 /*
- * random.c -- A strong random number generator
- *
  * Copyright (C) 2017-2022 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
- *
  * Copyright Matt Mackall <[email protected]>, 2003, 2004, 2005
- *
- * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All
- * rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions

drivers/char/random.c line 22

Quoted 10 lines
drivers/char/random.c +0 -10
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, and the entire permission notice in its entirety,
- *    including the disclaimer of warranties.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.

BSD-3, great.

drivers/char/random.c line 28

Quoted 6 lines
drivers/char/random.c +0 -6
- *
- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions.  (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)

I do not see a "or later" here.

Quoted 4 lines
drivers/char/random.c +0 -4
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF

drivers/char/random.c line 5

Quoted 10 lines
drivers/char/random.c +1 -9
- * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
+ * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All rights reserved.

Why break the line-wrap?

Quoted 8 lines
drivers/char/random.c +0 -0
  */
 
 /*
include/linux/random.h +0 -0
index e92efb39779c..1a6861aa1277 100644

include/linux/random.h line 6

Quoted 6 lines
include/linux/random.h +0 -5
@@ -1,9 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/*
- * include/linux/random.h
- *
- * Include file for the random number generator.
- */

This doesn't have to do with the SPDX change in the other file, it belongs in a different patch, sorry.

thanks,

greg k-h

author maintainer
#14 lore raw

Re: [PATCH v2] random: add proper SPDX header

Hi Greg,

Thanks for the review. Comments are inline below.

Quoted 2 lines · Greg Kroah-Hartman

Where did the "or later" come from? I don't see that in the original text.

Yea, this part seems a little bit ambiguous:

Quoted 7 lines
Quoted 5 lines

- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions. (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)

I do not see a "or later" here.

I don't see a "2.0" either. I think we can infer from context that it couldn't have been < 2.0. So in the absence of a number, maybe this means >= 2.0, and hence "or later"? Or since at the time it probably meant 2.0, do we infer this to mean == 2.0? I really have no idea, which is why I'm glad this list exists.

It sounds like your perspective is that this is == 2.0?

Quoted 6 lines
Quoted 6 lines
include/linux/random.h +0 -0
index e92efb39779c..1a6861aa1277 100644
@@ -1,9 +1,4 @@
 /* SPDX-License-Identifier: GPL-2.0 */
Quoted 8 lines

include/linux/random.h line 6

Quoted 5 lines
include/linux/random.h +0 -5
-/*
- * include/linux/random.h
- *
- * Include file for the random number generator.
- */

This doesn't have to do with the SPDX change in the other file, it belongs in a different patch, sorry.

Ack.

Jason

#15 lore raw

Re: [PATCH v2] random: add proper SPDX header

Quoted 19 lines · Jason A. Donenfeld

Hi Greg,

Thanks for the review. Comments are inline below.

Quoted 2 lines · Greg Kroah-Hartman

Where did the "or later" come from? I don't see that in the original text.

Yea, this part seems a little bit ambiguous:

Quoted 7 lines
Quoted 5 lines

- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions. (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)

I do not see a "or later" here.

Quoted 7 lines

I don't see a "2.0" either. I think we can infer from context that it couldn't have been < 2.0. So in the absence of a number, maybe this means >= 2.0, and hence "or later"? Or since at the time it probably meant 2.0, do we infer this to mean == 2.0? I really have no idea, which is why I'm glad this list exists.

It sounds like your perspective is that this is == 2.0?

Without a "or later" it has to be "2.0" as that is what the overall kernel license is. That's what we did for the big SPDX sweep, so that keeps things being decided in the same manner.

thanks,

greg k-h

author maintainer
#16 lore raw

Re: [PATCH v2] random: add proper SPDX header

Quoted 27 lines · Greg Kroah-Hartman
Quoted 25 lines · Jason A. Donenfeld

Hi Greg,

Thanks for the review. Comments are inline below.

Quoted 2 lines · Greg Kroah-Hartman

Where did the "or later" come from? I don't see that in the original text.

Yea, this part seems a little bit ambiguous:

Quoted 7 lines
Quoted 5 lines

- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions. (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)

I do not see a "or later" here.

I don't see a "2.0" either. I think we can infer from context that it couldn't have been < 2.0. So in the absence of a number, maybe this means >= 2.0, and hence "or later"? Or since at the time it probably meant 2.0, do we infer this to mean == 2.0? I really have no idea, which is why I'm glad this list exists.

Quoted 5 lines
Quoted 1 line

It sounds like your perspective is that this is == 2.0?

Without a "or later" it has to be "2.0" as that is what the overall kernel license is. That's what we did for the big SPDX sweep, so that keeps things being decided in the same manner.

Sounds good. v3 incoming.

Jason

author maintainer
#17 lore raw

PATCH v3 1/1 random: add proper SPDX header

Convert the current license into the SPDX notation of "(GPL-2.0 OR BSD-3-Clause)". This infers GPL-2.0 from the text "ALTERNATIVELY, this product may be distributed under the terms of the GNU General Public License, in which case the provisions of the GPL are required INSTEAD OF the above restrictions" and it infers BSD-3-Clause from the verbatim BSD 3 clause license in the file.

Cc Thomas Gleixner <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>

---
Changes v2->v3:
- GPL-2.0-or-later is now a vanilla GPL-2.0.
- Remove non-license changes.

 drivers/char/random.c | 37 +------------------------------------
 1 file changed, 1 insertion(+), 36 deletions(-)
drivers/char/random.c +1 -36
index 324574b03120..ea4a89129865 100644
@@ -1,44 +1,9 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
 /*
- * random.c -- A strong random number generator
- *
  * Copyright (C) 2017-2022 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
- *
  * Copyright Matt Mackall <[email protected]>, 2003, 2004, 2005
- *
  * Copyright Theodore Ts'o, 1994, 1995, 1996, 1997, 1998, 1999.  All
  * rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, and the entire permission notice in its entirety,
- *    including the disclaimer of warranties.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU General Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions.  (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
- * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
  */
 
 /*
Signature · 1 line
2.35.0
maintainer Reviewed-by on v3 1/1
#18 lore raw

Re: [PATCH v3] random: add proper SPDX header

Quoted 12 lines · Jason A. Donenfeld

Convert the current license into the SPDX notation of "(GPL-2.0 OR BSD-3-Clause)". This infers GPL-2.0 from the text "ALTERNATIVELY, this product may be distributed under the terms of the GNU General Public License, in which case the provisions of the GPL are required INSTEAD OF the above restrictions" and it infers BSD-3-Clause from the verbatim BSD 3 clause license in the file.

Cc Thomas Gleixner <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Dominik Brodowski <[email protected]>
Quoted 7 lines

---
Changes v2->v3:
- GPL-2.0-or-later is now a vanilla GPL-2.0.
- Remove non-license changes.

 drivers/char/random.c | 37 +------------------------------------
 1 file changed, 1 insertion(+), 36 deletions(-)