v2.6.34.13 longterm review
Subsystems (95)
PATCH 155/165 random: add new get_random_bytes_arch() function
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit c2557a303ab6712bb6e09447df828c557c710ac9 upstream.
Create a new function, get_random_bytes_arch() which will use the architecture-specific hardware random number generator if it is present. Change get_random_bytes() to not use the HW RNG, even if it is avaiable.
The reason for this is that the hw random number generator is fast (if it is present), but it requires that we trust the hardware manufacturer to have not put in a back door. (For example, an increasing counter encrypted by an AES key known to the NSA.)
It's unlikely that Intel (for example) was paid off by the US Government to do this, but it's impossible for them to prove otherwise
--- especially since Bull Mountain is documented to use AES as a
whitener. Hence, the output of an evil, trojan-horse version of RDRAND is statistically indistinguishable from an RDRAND implemented to the specifications claimed by Intel. Short of using a tunnelling electronic microscope to reverse engineer an Ivy Bridge chip and disassembling and analyzing the CPU microcode, there's no way for us to tell for sure.
Since users of get_random_bytes() in the Linux kernel need to be able to support hardware systems where the HW RNG is not present, most time-sensitive users of this interface have already created their own cryptographic RNG interface which uses get_random_bytes() as a seed. So it's much better to use the HW RNG to improve the existing random number generator, by mixing in any entropy returned by the HW RNG into /dev/random's entropy pool, but to always _use_ /dev/random's entropy pool.
This way we get almost of the benefits of the HW RNG without any potential liabilities. The only benefits we forgo is the speed/performance enhancements --- and generic kernel code can't depend on depend on get_random_bytes() having the speed of a HW RNG anyway.
For those places that really want access to the arch-specific HW RNG, if it is available, we provide get_random_bytes_arch().
--- drivers/char/random.c | 27 +++++++++++++++++++++++---- include/linux/random.h | 1 + 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/char/random.c +23 -4
@@ -1031,11 +1031,28 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,/* * This function is the exported kernel interface. It returns some -* number of good random numbers, suitable for seeding TCP sequence -* numbers, etc. +* number of good random numbers, suitable for key generation, seeding +* TCP sequence numbers, etc. It does not use the hw random number +* generator, if available; use get_random_bytes_arch() for that. */ void get_random_bytes (void *buf,int nbytes) { +extract_entropy (&nonblocking_pool, buf, nbytes,0 ,0 ); +} +EXPORT_SYMBOL (get_random_bytes); + +/* +* This function will use the architecture-specific hardware random +* number generator if it is available. The arch-specific hw RNG will +* almost certainly be faster than what we can do in software, but it +* is impossible to verify that it is implemented securely (as +* opposed, to, say, the AES encryption of a sequence number using a +* key known by the NSA). So it's useful if we need the speed, but +* only if we're willing to trust the hardware manufacturer not to +* have put in a back door. +*/ +void get_random_bytes_arch (void *buf,int nbytes) +{char *p = buf;while (nbytes) {
@@ -1050,9 +1067,11 @@ void get_random_bytes(void *buf, int nbytes) nbytes -= chunk; } -extract_entropy (&nonblocking_pool, p, nbytes,0 ,0 ); +if (nbytes) +extract_entropy (&nonblocking_pool, p, nbytes,0 ,0 ); } -EXPORT_SYMBOL (get_random_bytes); +EXPORT_SYMBOL (get_random_bytes_arch); +/* * init_std_data - initialize pool with system data
include/linux/random.h +1 -0
@@ -52,6 +52,7 @@ extern void add_input_randomness(unsigned int type, unsigned int code,extern void add_interrupt_randomness (int irq,int irq_flags);extern void get_random_bytes (void *buf,int nbytes); +extern void get_random_bytes_arch (void *buf,int nbytes);void generate_random_uuid (unsigned char uuid_out[16 ]);#ifndef MODULE
Signature · 1 line
1.7.12.rc2
PATCH 156/165 random: add tracepoints for easier debugging and verification
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 00ce1db1a634746040ace24c09a4e3a7949a3145 upstream.
--- drivers/char/random.c | 26 ++++++-- include/trace/events/random.h | 134 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 include/trace/events/random.h
drivers/char/random.c +22 -4
@@ -259,6 +259,9 @@#include <asm/irq_regs.h> #include <asm/io.h> +#define CREATE_TRACE_POINTS +#include <trace/events/random.h> +/* * Configuration information */
@@ -471,8 +474,8 @@ static __u32 const twist_table[8] = {* it's cheap to do so and helps slightly in the expected case where * the entropy is concentrated in the low-order bits. */ -static void __mix_pool_bytes (struct entropy_store *r,const void *in, -int nbytes,__u8 out[64 ]) +static void _mix_pool_bytes (struct entropy_store *r,const void *in, +int nbytes,__u8 out[64 ]) {unsigned long i, j, tap1, tap2, tap3, tap4, tap5;int input_rotate;
@@ -524,13 +527,21 @@ static void __mix_pool_bytes(struct entropy_store *r, const void *in, ((__u32 *)out)[j] = r->pool[(i - j) & wordmask]; } -static void mix_pool_bytes (struct entropy_store *r,const void *in, +static void __mix_pool_bytes (struct entropy_store *r,const void *in,int nbytes,__u8 out[64 ]) { +trace_mix_pool_bytes_nolock (r->name, nbytes, _RET_IP_); +_mix_pool_bytes (r, in, nbytes, out); +} + +static void mix_pool_bytes (struct entropy_store *r,const void *in, +int nbytes,__u8 out[64 ]) +{unsigned long flags; +trace_mix_pool_bytes (r->name, nbytes, _RET_IP_);spin_lock_irqsave (&r->lock, flags); -__mix_pool_bytes (r, in, nbytes, out); +_mix_pool_bytes (r, in, nbytes, out);spin_unlock_irqrestore (&r->lock, flags); }
@@ -578,6 +589,7 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) retry: entropy_count = orig =ACCESS_ONCE (r->entropy_count); entropy_count += nbits; +if (entropy_count <0 ) {DEBUG_ENT ("negative entropy/overflow\n" ); entropy_count =0 ;
@@ -592,6 +604,9 @@ retry: r->initialized =1 ; } +trace_credit_entropy_bits (r->name, nbits, entropy_count, + r->entropy_total, _RET_IP_); +/* should we wake readers? */ if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) {wake_up_interruptible (&random_read_wait);
@@ -964,6 +979,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,ssize_t ret =0 , i;__u8 tmp[EXTRACT_SIZE ]; +trace_extract_entropy (r->name, nbytes, r->entropy_count, _RET_IP_);xfer_secondary_pool (r, nbytes); nbytes =account (r, nbytes, min, reserved);
@@ -998,6 +1014,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,ssize_t ret =0 , i;__u8 tmp[EXTRACT_SIZE ]; +trace_extract_entropy_user (r->name, nbytes, r->entropy_count, _RET_IP_);xfer_secondary_pool (r, nbytes); nbytes =account (r, nbytes,0 ,0 );
@@ -1055,6 +1072,7 @@ void get_random_bytes_arch(void *buf, int nbytes) {char *p = buf; +trace_get_random_bytes (nbytes, _RET_IP_);while (nbytes) {unsigned long v;int chunk =min (nbytes, (int )sizeof (unsigned long ));
include/trace/events/random.h new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2
PATCH 157/165 random: mix in architectural randomness in extract_buf()
In reply to Paul GortmakerFrom: "H. Peter Anvin" <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit d2e7c96af1e54b507ae2a6a7dd2baf588417a7e5 upstream.
Mix in any architectural randomness in extract_buf() instead of xfer_secondary_buf(). This allows us to mix in more architectural randomness, and it also makes xfer_secondary_buf() faster, moving a tiny bit of additional CPU overhead to process which is extracting the randomness.
[ Commit description modified by tytso to remove an extended
advertisement for the RDRAND instruction. ]
--- drivers/char/random.c | 56 +++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-)
drivers/char/random.c +32 -24
@@ -270,6 +270,8 @@#define SEC_XFER_SIZE 512#define EXTRACT_SIZE 10 +#define LONGS (x) (((x) + sizeof(unsigned long) - 1)/sizeof(unsigned long)) +/* * The minimum number of bits of entropy before we wake up a read on * /dev/random. Should be enough to do a significant reseed.
@@ -843,11 +845,7 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,*/ static void xfer_secondary_pool (struct entropy_store *r,size_t nbytes) { -union { -__u32 tmp[OUTPUT_POOL_WORDS ]; -long hwrand[4 ]; - } u; -int i; +__u32 tmp[OUTPUT_POOL_WORDS ];if (r->pull && r->entropy_count < nbytes *8 && r->entropy_count < r->poolinfo->POOLBITS) {
@@ -858,23 +856,17 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)/* pull at least as many as BYTES as wakeup BITS */ bytes =max_t (int, bytes, random_read_wakeup_thresh /8 );/* but never more than the buffer size */ - bytes =min_t (int, bytes,sizeof (u.tmp)); + bytes =min_t (int, bytes,sizeof (tmp));DEBUG_ENT ("going to reseed %s with %d bits " "(%d of %d requested)\n" , r->name, bytes *8 , nbytes *8 , r->entropy_count); - bytes =extract_entropy (r->pull, u.tmp, bytes, + bytes =extract_entropy (r->pull, tmp, bytes, random_read_wakeup_thresh /8 , rsvd); -mix_pool_bytes (r, u.tmp, bytes,NULL ); +mix_pool_bytes (r, tmp, bytes,NULL );credit_entropy_bits (r, bytes*8 ); } -kmemcheck_mark_initialized (&u.hwrand,sizeof (u.hwrand)); -for (i =0 ; i <4 ; i++) -if (arch_get_random_long (&u.hwrand[i])) -break ; -if (i) -mix_pool_bytes (r, &u.hwrand,sizeof (u.hwrand),0 ); }/*
@@ -931,15 +923,19 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,static void extract_buf (struct entropy_store *r,__u8 *out) {int i; -__u32 hash[5 ], workspace[SHA_WORKSPACE_WORDS ]; +union { +__u32 w[5 ]; +unsigned long l[LONGS (EXTRACT_SIZE )]; + } hash; +__u32 workspace[SHA_WORKSPACE_WORDS ];__u8 extract[64 ];unsigned long flags;/* Generate a hash across the pool, 16 words (512 bits) at a time */ -sha_init (hash); +sha_init (hash.w);spin_lock_irqsave (&r->lock, flags);for (i =0 ; i < r->poolinfo->poolwords; i +=16 ) -sha_transform (hash, (__u8 *)(r->pool + i), workspace); +sha_transform (hash.w, (__u8 *)(r->pool + i), workspace);/* * We mix the hash back into the pool to prevent backtracking
@@ -950,14 +946,14 @@ static void extract_buf(struct entropy_store *r, __u8 *out)* brute-forcing the feedback as hard as brute-forcing the * hash. */ -__mix_pool_bytes (r, hash,sizeof (hash), extract); +__mix_pool_bytes (r, hash.w,sizeof (hash.w), extract);spin_unlock_irqrestore (&r->lock, flags);/* * To avoid duplicates, we atomically extract a portion of the * pool while mixing, and hash one final time. */ -sha_transform (hash, extract, workspace); +sha_transform (hash.w, extract, workspace);memset (extract,0 ,sizeof (extract));memset (workspace,0 ,sizeof (workspace));
@@ -966,11 +962,23 @@ static void extract_buf(struct entropy_store *r, __u8 *out)* pattern, we fold it in half. Thus, we always feed back * twice as much data as we output. */ - hash[0 ] ^= hash[3 ]; - hash[1 ] ^= hash[4 ]; - hash[2 ] ^=rol32 (hash[2 ],16 ); -memcpy (out, hash,EXTRACT_SIZE ); -memset (hash,0 ,sizeof (hash)); + hash.w[0 ] ^= hash.w[3 ]; + hash.w[1 ] ^= hash.w[4 ]; + hash.w[2 ] ^=rol32 (hash.w[2 ],16 ); + +/* +* If we have a architectural hardware random number +* generator, mix that in, too. +*/ +for (i =0 ; i <LONGS (EXTRACT_SIZE ); i++) { +unsigned long v; +if (!arch_get_random_long (&v)) +break ; + hash.l[i] ^= v; + } + +memcpy (out, &hash,EXTRACT_SIZE ); +memset (&hash,0 ,sizeof (hash)); } static ssize_t extract_entropy(struct entropy_store *r, void *buf,
Signature · 1 line
1.7.12.rc2
PATCH 158/165 MAINTAINERS: Theodore Ts'o is taking over the random driver
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 330e0a01d54c2b8606c56816f99af6ebc58ec92c upstream.
Matt Mackall stepped down as the /dev/random driver maintainer last year, so Theodore Ts'o is taking back the /dev/random driver.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -4644,7 +4644,7 @@ F: Documentation/blockdev/ramdisk.txt F: drivers/block/brd.c RANDOM NUMBER DRIVER -M: Matt Mackall <[email protected]> +M: Theodore Ts'o" <[email protected]> S: Maintained F: drivers/char/random.c
Signature · 1 line
1.7.12.rc2
PATCH 159/165 usb: feed USB device information to the /dev/random driver
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit b04b3156a20d395a7faa8eed98698d1e17a36000 upstream.
Send the USB device's serial, product, and manufacturer strings to the /dev/random driver to help seed its pools.
--- drivers/usb/core/hub.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/usb/core/hub.c +9 -0
@@ -23,6 +23,7 @@#include <linux/mutex.h> #include <linux/freezer.h> #include <linux/pm_runtime.h> +#include <linux/random.h> #include <asm/uaccess.h> #include <asm/byteorder.h>
@@ -1827,6 +1828,14 @@ int usb_new_device(struct usb_device *udev)/* Tell the world! */ announce_device (udev); +if (udev->serial) +add_device_randomness (udev->serial,strlen (udev->serial)); +if (udev->product) +add_device_randomness (udev->product,strlen (udev->product)); +if (udev->manufacturer) +add_device_randomness (udev->manufacturer, +strlen (udev->manufacturer)); +device_enable_async_suspend (&udev->dev);/* Register the device. The device driver is responsible * for configuring the device and invoking the add-device
Signature · 1 line
1.7.12.rc2
PATCH 160/165 net: feed /dev/random with the MAC address when registering a device
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 7bf2357524408b97fec58344caf7397f8140c3fd upstream.
--- net/core/dev.c | 3 +++ net/core/rtnetlink.c | 1 + 2 files changed, 4 insertions(+)
net/core/dev.c +3 -0
@@ -1177,6 +1177,7 @@ static int __dev_open(struct net_device *dev)* Wakeup transmit queue engine */ dev_activate (dev); +add_device_randomness (dev->dev_addr, dev->addr_len); }return ret;
@@ -4492,6 +4493,7 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) err = ops->ndo_set_mac_address (dev, sa);if (!err)call_netdevice_notifiers (NETDEV_CHANGEADDR , dev); +add_device_randomness (dev->dev_addr, dev->addr_len);return err; }EXPORT_SYMBOL (dev_set_mac_address);
@@ -5141,6 +5143,7 @@ int register_netdevice(struct net_device *dev)dev_init_scheduler (dev);dev_hold (dev);list_netdevice (dev); +add_device_randomness (dev->dev_addr, dev->addr_len);/* Notify protocols, that a new device appeared. */ ret =call_netdevice_notifiers (NETDEV_REGISTER , dev);
net/core/rtnetlink.c +1 -0
@@ -974,6 +974,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, goto errout; send_addr_notify =1 ; modified =1 ; +add_device_randomness (dev->dev_addr, dev->addr_len); }if (tb[IFLA_MTU ]) {
Signature · 1 line
1.7.12.rc2
PATCH 161/165 random: remove rand_initialize_irq()
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit c5857ccf293968348e5eb4ebedc68074de3dcda6 upstream.
With the new interrupt sampling system, we are no longer using the timer_rand_state structure in the irq descriptor, so we can stop initializing it now.
[ Merged in fixes from Sedat to find some last missing references to
rand_initialize_irq() ]
--- arch/ia64/kernel/irq_ia64.c | 1 - drivers/char/random.c | 55 --------------------------------------------- drivers/mfd/ab3100-core.c | 3 --- include/linux/irq.h | 1 - include/linux/random.h | 2 -- kernel/irq/manage.c | 17 -------------- 6 files changed, 79 deletions(-)
arch/ia64/kernel/irq_ia64.c +0 -1
@@ -23,7 +23,6 @@#include <linux/ioport.h> #include <linux/kernel_stat.h> #include <linux/ptrace.h> -#include <linux/random.h> /* for rand_initialize_irq() */ #include <linux/signal.h> #include <linux/smp.h> #include <linux/threads.h>
drivers/char/random.c +0 -55
67 lines not on this page · raw message
drivers/mfd/ab3100-core.c +0 -3
@@ -890,9 +890,6 @@ static int __init ab3100_probe(struct i2c_client *client, err =request_threaded_irq (client->irq,NULL , ab3100_irq_handler,IRQF_ONESHOT ,"ab3100-core" , ab3100); -/* This real unpredictable IRQ is of course sampled for entropy */ -rand_initialize_irq (client->irq); -if (err) goto exit_no_irq;
include/linux/irq.h +0 -1
@@ -174,7 +174,6 @@ struct irq_2_iommu;*/ struct irq_desc {unsigned int irq; -struct timer_rand_state *timer_rand_state;unsigned int *kstat_irqs;#ifdef CONFIG_INTR_REMAP struct irq_2_iommu *irq_2_iommu;
include/linux/random.h +0 -2
@@ -44,8 +44,6 @@ struct rand_pool_info {#ifdef __KERNEL__ -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);
kernel/irq/manage.c +0 -17
@@ -652,22 +652,6 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)if (desc->chip == &no_irq_chip)return -ENOSYS ; -/* -* Some drivers like serial.c use request_irq() heavily, -* so we have to be careful not to interfere with a -* running system. -*/ -if (new->flags &IRQF_SAMPLE_RANDOM ) { -/* -* This function might sleep, we want to call it first, -* outside of the atomic block. -* Yes, this might clear the entropy pool if the wrong -* driver is attempted to be loaded, without actually -* installing a new handler, but is this really a problem, -* only the sysadmin is able to do this. -*/ -rand_initialize_irq (irq); - }/* Oneshot interrupts are not allowed with shared */ if ((new->flags &IRQF_ONESHOT ) && (new->flags &IRQF_SHARED ))
@@ -1040,7 +1024,6 @@ EXPORT_SYMBOL(free_irq);* * IRQF_SHARED Interrupt is shared * IRQF_DISABLED Disable local interrupts while processing -* IRQF_SAMPLE_RANDOM The interrupt can be used for entropy * IRQF_TRIGGER_* Specify active edge(s) or level * */
Signature · 1 line
1.7.12.rc2
PATCH 162/165 random: Add comment to random_initialize()
In reply to Paul GortmakerFrom: Tony Luck <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit cbc96b7594b5691d61eba2db8b2ea723645be9ca upstream.
Many platforms have per-machine instance data (serial numbers, asset tags, etc.) squirreled away in areas that are accessed during early system bringup. Mixing this data into the random pools has a very high value in providing better random data, so we should allow (and even encourage) architecture code to call add_device_randomness() from the setup_arch() paths.
However, this limits our options for internal structure of the random driver since random_initialize() is not called until long after setup_arch().
Add a big fat comment to rand_initialize() spelling out this requirement.
--- drivers/char/random.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/char/random.c +10 -0
@@ -1088,6 +1088,16 @@ static void init_std_data(struct entropy_store *r)mix_pool_bytes (r,utsname (),sizeof (*(utsname ())),NULL ); } +/* +* Note that setup_arch() may call add_device_randomness() +* long before we get here. This allows seeding of the pools +* with some platform dependent data very early in the boot +* process. But it limits our options here. We must use +* statically allocated structures that already have all +* initializations complete at compile time. We should also +* take care not to overwrite the precious per platform data +* we were given. +*/ static int rand_initialize (void ) {init_std_data (&input_pool);
Signature · 1 line
1.7.12.rc2
PATCH 163/165 rtc: wm831x: Feed the write counter into device_add_randomness()
In reply to Paul GortmakerFrom: Mark Brown <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 9dccf55f4cb011a7552a8a2749a580662f5ed8ed upstream.
The tamper evident features of the RTC include the "write counter" which is a pseudo-random number regenerated whenever we set the RTC. Since this value is unpredictable it should provide some useful seeding to the random number generator.
Only do this on boot since the goal is to seed the pool rather than add useful entropy.
--- drivers/rtc/rtc-wm831x.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/rtc/rtc-wm831x.c +23 -1
@@ -24,7 +24,7 @@#include <linux/mfd/wm831x/core.h> #include <linux/delay.h> #include <linux/platform_device.h> - +#include <linux/random.h> /* * R16416 (0x4020) - RTC Write Counter
@@ -96,6 +96,26 @@ struct wm831x_rtc { unsigned int alarm_enabled:1; }; +static void wm831x_rtc_add_randomness (struct wm831x *wm831x) +{ +int ret; +u16 reg; + +/* +* The write counter contains a pseudo-random number which is +* regenerated every time we set the RTC so it should be a +* useful per-system source of entropy. +*/ + ret =wm831x_reg_read (wm831x,WM831X_RTC_WRITE_COUNTER ); +if (ret >=0 ) { + reg = ret; +add_device_randomness (®,sizeof (reg)); + }else { +dev_warn (wm831x->dev,"Failed to read RTC write counter: %d\n" , + ret); + } +} +/* * Read current time and date in RTC */
@@ -465,6 +485,8 @@ static int wm831x_rtc_probe(struct platform_device *pdev) alm_irq, ret); } +wm831x_rtc_add_randomness (wm831x); +return 0 ; err:
Signature · 1 line
1.7.12.rc2
PATCH 164/165 mfd: wm831x: Feed the device UUID into device_add_randomness()
In reply to Paul GortmakerFrom: Mark Brown <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 27130f0cc3ab97560384da437e4621fc4e94f21c upstream.
wm831x devices contain a unique ID value. Feed this into the newly added device_add_randomness() to add some per device seed data to the pool.
--- drivers/mfd/wm831x-otp.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mfd/wm831x-otp.c +8 -0
@@ -18,6 +18,7 @@#include <linux/bcd.h> #include <linux/delay.h> #include <linux/mfd/core.h> +#include <linux/random.h> #include <linux/mfd/wm831x/core.h> #include <linux/mfd/wm831x/otp.h>
@@ -66,6 +67,7 @@ static DEVICE_ATTR(unique_id, 0444, wm831x_unique_id_show, NULL);int wm831x_otp_init (struct wm831x *wm831x) { +char uuid[WM831X_UNIQUE_ID_LEN ];int ret; ret =device_create_file (wm831x->dev, &dev_attr_unique_id);
@@ -73,6 +75,12 @@ int wm831x_otp_init(struct wm831x *wm831x)dev_err (wm831x->dev,"Unique ID attribute not created: %d\n" , ret); + ret =wm831x_unique_id_read (wm831x, uuid); +if (ret ==0 ) +add_device_randomness (uuid,sizeof (uuid)); +else +dev_err (wm831x->dev,"Failed to read UUID: %d\n" , ret); +return ret; }
Signature · 1 line
1.7.12.rc2
PATCH 165/165 dmi: Feed DMI table to /dev/random driver
In reply to Paul GortmakerFrom: Tony Luck <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit d114a33387472555188f142ed8e98acdb8181c6d upstream.
Send the entire DMI (SMBIOS) table to the /dev/random driver to help seed its pools.
--- drivers/firmware/dmi_scan.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/firmware/dmi_scan.c +3 -0
@@ -5,6 +5,7 @@#include <linux/dmi.h> #include <linux/efi.h> #include <linux/bootmem.h> +#include <linux/random.h> #include <asm/dmi.h> /*
@@ -110,6 +111,8 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,dmi_table (buf, dmi_len, dmi_num, decode,NULL ); +add_device_randomness (buf, dmi_len); +dmi_iounmap (buf, dmi_len);return 0 ; }
Signature · 1 line
1.7.12.rc2