]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.5-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Aug 2012 19:49:15 +0000 (12:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Aug 2012 19:49:15 +0000 (12:49 -0700)
added patches:
random-create-add_device_randomness-interface.patch

queue-3.5/random-create-add_device_randomness-interface.patch [new file with mode: 0644]
queue-3.5/series

diff --git a/queue-3.5/random-create-add_device_randomness-interface.patch b/queue-3.5/random-create-add_device_randomness-interface.patch
new file mode 100644 (file)
index 0000000..ea82fce
--- /dev/null
@@ -0,0 +1,89 @@
+From a2080a67abe9e314f9e9c2cc3a4a176e8a8f8793 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Wed, 4 Jul 2012 11:16:01 -0400
+Subject: random: create add_device_randomness() interface
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit a2080a67abe9e314f9e9c2cc3a4a176e8a8f8793 upstream.
+
+Add a new interface, add_device_randomness() for adding data to the
+random pool that is likely to differ between two devices (or possibly
+even per boot).  This would be things like MAC addresses or serial
+numbers, or the read-out of the RTC. This does *not* add any actual
+entropy to the pool, but it initializes the pool to different values
+for devices that might otherwise be identical and have very little
+entropy available to them (particularly common in the embedded world).
+
+[ Modified by tytso to mix in a timestamp, since there may be some
+  variability caused by the time needed to detect/configure the hardware
+  in question. ]
+
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/char/random.c  |   28 ++++++++++++++++++++++++++++
+ include/linux/random.h |    1 +
+ 2 files changed, 29 insertions(+)
+
+--- a/drivers/char/random.c
++++ b/drivers/char/random.c
+@@ -125,11 +125,20 @@
+  * The current exported interfaces for gathering environmental noise
+  * from the devices are:
+  *
++ *    void add_device_randomness(const void *buf, unsigned int size);
+  *    void add_input_randomness(unsigned int type, unsigned int code,
+  *                                unsigned int value);
+  *    void add_interrupt_randomness(int irq, int irq_flags);
+  *    void add_disk_randomness(struct gendisk *disk);
+  *
++ * add_device_randomness() is for adding data to the random pool that
++ * is likely to differ between two devices (or possibly even per boot).
++ * This would be things like MAC addresses or serial numbers, or the
++ * read-out of the RTC. This does *not* add any actual entropy to the
++ * pool, but it initializes the pool to different values for devices
++ * that might otherwise be identical and have very little entropy
++ * available to them (particularly common in the embedded world).
++ *
+  * add_input_randomness() uses the input layer interrupt timing, as well as
+  * the event type information from the hardware.
+  *
+@@ -646,6 +655,25 @@ static void set_timer_rand_state(unsigne
+ }
+ #endif
++/*
++ * Add device- or boot-specific data to the input and nonblocking
++ * pools to help initialize them to unique values.
++ *
++ * None of this adds any entropy, it is meant to avoid the
++ * problem of the nonblocking pool having similar initial state
++ * across largely identical devices.
++ */
++void add_device_randomness(const void *buf, unsigned int size)
++{
++      unsigned long time = get_cycles() ^ jiffies;
++
++      mix_pool_bytes(&input_pool, buf, size, NULL);
++      mix_pool_bytes(&input_pool, &time, sizeof(time), NULL);
++      mix_pool_bytes(&nonblocking_pool, buf, size, NULL);
++      mix_pool_bytes(&nonblocking_pool, &time, sizeof(time), NULL);
++}
++EXPORT_SYMBOL(add_device_randomness);
++
+ static struct timer_rand_state input_timer_state;
+ /*
+--- a/include/linux/random.h
++++ b/include/linux/random.h
+@@ -50,6 +50,7 @@ struct rnd_state {
+ extern void rand_initialize_irq(int irq);
++extern void add_device_randomness(const void *, unsigned int);
+ extern void add_input_randomness(unsigned int type, unsigned int code,
+                                unsigned int value);
+ extern void add_interrupt_randomness(int irq, int irq_flags);
index 2138201c34c050ca051281bcdad3aa79466d74f4..25c14cc600e87606c808ad51238d58a7d978c233 100644 (file)
@@ -45,3 +45,4 @@ x86-64-kcmp-the-kcmp-system-call-can-be-common.patch
 input-synaptics-handle-out-of-bounds-values-from-the-hardware.patch
 random-make-add_interrupt_randomness-do-something-sane.patch
 random-use-lockless-techniques-in-the-interrupt-path.patch
+random-create-add_device_randomness-interface.patch