Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2018-10-30 09:07:07 +0100
committerJiri Slaby <jslaby@suse.cz>2018-10-30 10:12:06 +0100
commitbe52b925c3b32b625cfefe2da159a0fe8e0e1392 (patch)
tree6db5fea406ac01ed2bc8bf01635521faad727cf2
parentfef370da580ada9c45b0fc5d1deaa9c619589197 (diff)
random: rate limit unseeded randomness warnings (git-fixes).
-rw-r--r--patches.suse/random-rate-limit-unseeded-randomness-warnings.patch89
-rw-r--r--series.conf1
2 files changed, 90 insertions, 0 deletions
diff --git a/patches.suse/random-rate-limit-unseeded-randomness-warnings.patch b/patches.suse/random-rate-limit-unseeded-randomness-warnings.patch
new file mode 100644
index 0000000000..31e82d03fb
--- /dev/null
+++ b/patches.suse/random-rate-limit-unseeded-randomness-warnings.patch
@@ -0,0 +1,89 @@
+From: Theodore Ts'o <tytso@mit.edu>
+Date: Wed, 25 Apr 2018 01:12:32 -0400
+Subject: random: rate limit unseeded randomness warnings
+Git-commit: 4e00b339e264802851aff8e73cde7d24b57b18ce
+Patch-mainline: v4.17-rc3
+References: git-fixes
+
+On systems without sufficient boot randomness, no point spamming dmesg.
+
+[js] dropped hunk for unseeded_warning as it is not built anyway
+
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Cc: stable@vger.kernel.org
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ drivers/char/random.c | 34 +++++++++++++++++++++++++++++++---
+ 1 file changed, 31 insertions(+), 3 deletions(-)
+
+--- a/drivers/char/random.c
++++ b/drivers/char/random.c
+@@ -262,6 +262,7 @@
+ #include <linux/kmemcheck.h>
+ #include <linux/workqueue.h>
+ #include <linux/irq.h>
++#include <linux/ratelimit.h>
+ #include <linux/syscalls.h>
+ #include <linux/completion.h>
+ #include <linux/uuid.h>
+@@ -439,6 +440,16 @@ static void _crng_backtrack_protect(stru
+ __u8 tmp[CHACHA20_BLOCK_SIZE], int used);
+ static void process_random_ready_list(void);
+
++static struct ratelimit_state unseeded_warning =
++ RATELIMIT_STATE_INIT("warn_unseeded_randomness", HZ, 3);
++static struct ratelimit_state urandom_warning =
++ RATELIMIT_STATE_INIT("warn_urandom_randomness", HZ, 3);
++
++static int ratelimit_disable __read_mostly;
++
++module_param_named(ratelimit_disable, ratelimit_disable, int, 0644);
++MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression");
++
+ /**********************************************************************
+ *
+ * OS independent entropy store. Here are the functions which handle
+@@ -932,6 +943,18 @@ static void crng_reseed(struct crng_stat
+ process_random_ready_list();
+ wake_up_interruptible(&crng_init_wait);
+ pr_notice("random: crng init done\n");
++ if (unseeded_warning.missed) {
++ pr_notice("random: %d get_random_xx warning(s) missed "
++ "due to ratelimiting\n",
++ unseeded_warning.missed);
++ unseeded_warning.missed = 0;
++ }
++ if (urandom_warning.missed) {
++ pr_notice("random: %d urandom warning(s) missed "
++ "due to ratelimiting\n",
++ urandom_warning.missed);
++ urandom_warning.missed = 0;
++ }
+ }
+ }
+
+@@ -1743,6 +1766,10 @@ static int rand_initialize(void)
+ init_std_data(&blocking_pool);
+ crng_initialize(&primary_crng);
+ crng_global_init_time = jiffies;
++ if (ratelimit_disable) {
++ urandom_warning.interval = 0;
++ unseeded_warning.interval = 0;
++ }
+ return 0;
+ }
+ early_initcall(rand_initialize);
+@@ -1810,9 +1837,10 @@ urandom_read(struct file *file, char __u
+
+ if (!crng_ready() && maxwarn > 0) {
+ maxwarn--;
+- printk(KERN_NOTICE "random: %s: uninitialized urandom read "
+- "(%zd bytes read)\n",
+- current->comm, nbytes);
++ if (__ratelimit(&urandom_warning))
++ printk(KERN_NOTICE "random: %s: uninitialized "
++ "urandom read (%zd bytes read)\n",
++ current->comm, nbytes);
+ spin_lock_irqsave(&primary_crng.lock, flags);
+ crng_init_cnt = 0;
+ spin_unlock_irqrestore(&primary_crng.lock, flags);
diff --git a/series.conf b/series.conf
index b1afe9305d..8019f31dc8 100644
--- a/series.conf
+++ b/series.conf
@@ -15236,6 +15236,7 @@
patches.arch/s390-dasd-fix-IO-error-for-newly-defined-devices.patch
patches.arch/s390-correct-module-section-names-for-expoline-code.patch
patches.drivers/random-fix-possible-sleeping-allocation-from-irq-con
+ patches.suse/random-rate-limit-unseeded-randomness-warnings.patch
patches.drivers/ACPI-scan-Initialize-watchdog-before-PNP.patch
patches.drivers/ACPI-watchdog-Prefer-iTCO_wdt-on-Lenovo-Z50-70
patches.drivers/ACPI-button-make-module-loadable-when-booted-in-non-