Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.30-rc5 /drivers/char/random.c

Filename:/drivers/char/random.c
Lines Added:19
Lines Deleted:9
Also changed in: (Previous) 2.6.30-rc4-git4  2.6.30-rc4  2.6.30-rc3  2.6.30-rc2  2.6.30-rc1  2.6.29-git15 
(Following) 2.6.30-rc6  2.6.30-rc6-git5  2.6.30-rc6-git6  2.6.30-rc6-git7  2.6.30-rc6-git8  2.6.30-rc7 

Location
[  2.6.30-rc5
  [  drivers
    [  char
       o  random.c

Patch

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 7c13581..b2ced39 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -241,6 +241,10 @@
 #include <linux/percpu.h>
 #include <linux/cryptohash.h>
 
+#ifdef CONFIG_GENERIC_HARDIRQS
+# include <linux/irq.h>
+#endif
+
 #include <asm/processor.h>
 #include <asm/uaccess.h>
 #include <asm/irq.h>
@@ -558,7 +562,7 @@ struct timer_rand_state {
    unsigned dont_count_entropy:1;
 };
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 
 static struct timer_rand_state *irq_timer_state[NR_IRQS];
 
@@ -1484,7 +1488,8 @@ static void rekey_seq_generator(struct work_struct *work)
    keyptr->count = (ip_cnt & COUNT_MASK) << HASH_BITS;
    smp_wmb();
    ip_cnt++;
-   schedule_delayed_work(&rekey_work, REKEY_INTERVAL);
+   schedule_delayed_work(&rekey_work,
+               round_jiffies_relative(REKEY_INTERVAL));
 }
 
 static inline struct keydata *get_keyptr(void)
@@ -1660,15 +1665,20 @@ EXPORT_SYMBOL(secure_dccp_sequence_number);
  * value is not cryptographically secure but for several uses the cost of
  * depleting entropy is too high
  */
+DEFINE_PER_CPU(__u32 [4], get_random_int_hash);
 unsigned int get_random_int(void)
 {
-   /*
-    * Use IP's RNG. It suits our purpose perfectly: it re-keys itself
-    * every second, from the entropy pool (and thus creates a limited
-    * drain on it), and uses halfMD4Transform within the second. We
-    * also mix it with jiffies and the PID:
-    */
-   return secure_ip_id((__force __be32)(current->pid + jiffies));
+   struct keydata *keyptr;
+   __u32 *hash = get_cpu_var(get_random_int_hash);
+   int ret;
+
+   keyptr = get_keyptr();
+   hash[0] += current->pid + jiffies + get_cycles() + (int)(long)&ret;
+
+   ret = half_md4_transform(hash, keyptr->secret);
+   put_cpu_var(get_random_int_hash);
+
+   return ret;
 }
 
 /*


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.