diff options
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r-- | drivers/char/random.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 7c13581ca9cd..b2ced39d76b2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -241,6 +241,10 @@ | |||
241 | #include <linux/percpu.h> | 241 | #include <linux/percpu.h> |
242 | #include <linux/cryptohash.h> | 242 | #include <linux/cryptohash.h> |
243 | 243 | ||
244 | #ifdef CONFIG_GENERIC_HARDIRQS | ||
245 | # include <linux/irq.h> | ||
246 | #endif | ||
247 | |||
244 | #include <asm/processor.h> | 248 | #include <asm/processor.h> |
245 | #include <asm/uaccess.h> | 249 | #include <asm/uaccess.h> |
246 | #include <asm/irq.h> | 250 | #include <asm/irq.h> |
@@ -558,7 +562,7 @@ struct timer_rand_state { | |||
558 | unsigned dont_count_entropy:1; | 562 | unsigned dont_count_entropy:1; |
559 | }; | 563 | }; |
560 | 564 | ||
561 | #ifndef CONFIG_SPARSE_IRQ | 565 | #ifndef CONFIG_GENERIC_HARDIRQS |
562 | 566 | ||
563 | static struct timer_rand_state *irq_timer_state[NR_IRQS]; | 567 | static struct timer_rand_state *irq_timer_state[NR_IRQS]; |
564 | 568 | ||
@@ -1484,7 +1488,8 @@ static void rekey_seq_generator(struct work_struct *work) | |||
1484 | keyptr->count = (ip_cnt & COUNT_MASK) << HASH_BITS; | 1488 | keyptr->count = (ip_cnt & COUNT_MASK) << HASH_BITS; |
1485 | smp_wmb(); | 1489 | smp_wmb(); |
1486 | ip_cnt++; | 1490 | ip_cnt++; |
1487 | schedule_delayed_work(&rekey_work, REKEY_INTERVAL); | 1491 | schedule_delayed_work(&rekey_work, |
1492 | round_jiffies_relative(REKEY_INTERVAL)); | ||
1488 | } | 1493 | } |
1489 | 1494 | ||
1490 | static inline struct keydata *get_keyptr(void) | 1495 | static inline struct keydata *get_keyptr(void) |
@@ -1660,15 +1665,20 @@ EXPORT_SYMBOL(secure_dccp_sequence_number); | |||
1660 | * value is not cryptographically secure but for several uses the cost of | 1665 | * value is not cryptographically secure but for several uses the cost of |
1661 | * depleting entropy is too high | 1666 | * depleting entropy is too high |
1662 | */ | 1667 | */ |
1668 | DEFINE_PER_CPU(__u32 [4], get_random_int_hash); | ||
1663 | unsigned int get_random_int(void) | 1669 | unsigned int get_random_int(void) |
1664 | { | 1670 | { |
1665 | /* | 1671 | struct keydata *keyptr; |
1666 | * Use IP's RNG. It suits our purpose perfectly: it re-keys itself | 1672 | __u32 *hash = get_cpu_var(get_random_int_hash); |
1667 | * every second, from the entropy pool (and thus creates a limited | 1673 | int ret; |
1668 | * drain on it), and uses halfMD4Transform within the second. We | 1674 | |
1669 | * also mix it with jiffies and the PID: | 1675 | keyptr = get_keyptr(); |
1670 | */ | 1676 | hash[0] += current->pid + jiffies + get_cycles() + (int)(long)&ret; |
1671 | return secure_ip_id((__force __be32)(current->pid + jiffies)); | 1677 | |
1678 | ret = half_md4_transform(hash, keyptr->secret); | ||
1679 | put_cpu_var(get_random_int_hash); | ||
1680 | |||
1681 | return ret; | ||
1672 | } | 1682 | } |
1673 | 1683 | ||
1674 | /* | 1684 | /* |