This is a note to let you know that I've just added the patch titled
random: use the arch-specific rng in xfer_secondary_pool
to the 3.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch
and it can be found in the queue-3.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From e6d4947b12e8ad947add1032dd754803c6004824 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Thu, 5 Jul 2012 10:21:01 -0400
Subject: random: use the arch-specific rng in xfer_secondary_pool
From: Theodore Ts'o <[email protected]>
commit e6d4947b12e8ad947add1032dd754803c6004824 upstream.
If the CPU supports a hardware random number generator, use it in
xfer_secondary_pool(), where it will significantly improve things and
where we can afford it.
Also, remove the use of the arch-specific rng in
add_timer_randomness(), since the call is significantly slower than
get_cycles(), and we're much better off using it in
xfer_secondary_pool() anyway.
Signed-off-by: "Theodore Ts'o" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/char/random.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -254,6 +254,7 @@
#include <linux/cryptohash.h>
#include <linux/fips.h>
#include <linux/ptrace.h>
+#include <linux/kmemcheck.h>
#ifdef CONFIG_GENERIC_HARDIRQS
# include <linux/irq.h>
@@ -702,11 +703,7 @@ static void add_timer_randomness(struct
goto out;
sample.jiffies = jiffies;
-
- /* Use arch random value, fall back to cycles */
- if (!arch_get_random_int(&sample.cycles))
- sample.cycles = get_cycles();
-
+ sample.cycles = get_cycles();
sample.num = num;
mix_pool_bytes(&input_pool, &sample, sizeof(sample), NULL);
@@ -838,7 +835,11 @@ static ssize_t extract_entropy(struct en
*/
static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
{
- __u32 tmp[OUTPUT_POOL_WORDS];
+ union {
+ __u32 tmp[OUTPUT_POOL_WORDS];
+ long hwrand[4];
+ } u;
+ int i;
if (r->pull && r->entropy_count < nbytes * 8 &&
r->entropy_count < r->poolinfo->POOLBITS) {
@@ -849,17 +850,23 @@ static void xfer_secondary_pool(struct e
/* 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(tmp));
+ bytes = min_t(int, bytes, sizeof(u.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, tmp, bytes,
+ bytes = extract_entropy(r->pull, u.tmp, bytes,
random_read_wakeup_thresh / 8, rsvd);
- mix_pool_bytes(r, tmp, bytes, NULL);
+ mix_pool_bytes(r, u.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);
}
/*
Patches currently in stable-queue which might be from [email protected] are
queue-3.4/maintainers-theodore-ts-o-is-taking-over-the-random-driver.patch
queue-3.4/usb-feed-usb-device-information-to-the-dev-random-driver.patch
queue-3.4/rtc-wm831x-feed-the-write-counter-into-device_add_randomness.patch
queue-3.4/random-add-comment-to-random_initialize.patch
queue-3.4/random-add-new-get_random_bytes_arch-function.patch
queue-3.4/random-add-tracepoints-for-easier-debugging-and-verification.patch
queue-3.4/random-make-add_interrupt_randomness-do-something-sane.patch
queue-3.4/dmi-feed-dmi-table-to-dev-random-driver.patch
queue-3.4/random-use-lockless-techniques-in-the-interrupt-path.patch
queue-3.4/random-mix-in-architectural-randomness-in-extract_buf.patch
queue-3.4/random-remove-rand_initialize_irq.patch
queue-3.4/net-feed-dev-random-with-the-mac-address-when-registering-a-device.patch
queue-3.4/random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch
queue-3.4/mfd-wm831x-feed-the-device-uuid-into-device_add_randomness.patch
queue-3.4/random-create-add_device_randomness-interface.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html