diff options
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r-- | drivers/char/random.c | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index b9dc7aa1dfb3..46c1b97748b6 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -881,15 +881,15 @@ EXPORT_SYMBOL(get_random_bytes); | |||
881 | */ | 881 | */ |
882 | static void init_std_data(struct entropy_store *r) | 882 | static void init_std_data(struct entropy_store *r) |
883 | { | 883 | { |
884 | struct timeval tv; | 884 | ktime_t now; |
885 | unsigned long flags; | 885 | unsigned long flags; |
886 | 886 | ||
887 | spin_lock_irqsave(&r->lock, flags); | 887 | spin_lock_irqsave(&r->lock, flags); |
888 | r->entropy_count = 0; | 888 | r->entropy_count = 0; |
889 | spin_unlock_irqrestore(&r->lock, flags); | 889 | spin_unlock_irqrestore(&r->lock, flags); |
890 | 890 | ||
891 | do_gettimeofday(&tv); | 891 | now = ktime_get_real(); |
892 | add_entropy_words(r, (__u32 *)&tv, sizeof(tv)/4); | 892 | add_entropy_words(r, (__u32 *)&now, sizeof(now)/4); |
893 | add_entropy_words(r, (__u32 *)utsname(), | 893 | add_entropy_words(r, (__u32 *)utsname(), |
894 | sizeof(*(utsname()))/4); | 894 | sizeof(*(utsname()))/4); |
895 | } | 895 | } |
@@ -911,14 +911,12 @@ void rand_initialize_irq(int irq) | |||
911 | return; | 911 | return; |
912 | 912 | ||
913 | /* | 913 | /* |
914 | * If kmalloc returns null, we just won't use that entropy | 914 | * If kzalloc returns null, we just won't use that entropy |
915 | * source. | 915 | * source. |
916 | */ | 916 | */ |
917 | state = kmalloc(sizeof(struct timer_rand_state), GFP_KERNEL); | 917 | state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL); |
918 | if (state) { | 918 | if (state) |
919 | memset(state, 0, sizeof(struct timer_rand_state)); | ||
920 | irq_timer_state[irq] = state; | 919 | irq_timer_state[irq] = state; |
921 | } | ||
922 | } | 920 | } |
923 | 921 | ||
924 | #ifdef CONFIG_BLOCK | 922 | #ifdef CONFIG_BLOCK |
@@ -927,14 +925,12 @@ void rand_initialize_disk(struct gendisk *disk) | |||
927 | struct timer_rand_state *state; | 925 | struct timer_rand_state *state; |
928 | 926 | ||
929 | /* | 927 | /* |
930 | * If kmalloc returns null, we just won't use that entropy | 928 | * If kzalloc returns null, we just won't use that entropy |
931 | * source. | 929 | * source. |
932 | */ | 930 | */ |
933 | state = kmalloc(sizeof(struct timer_rand_state), GFP_KERNEL); | 931 | state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL); |
934 | if (state) { | 932 | if (state) |
935 | memset(state, 0, sizeof(struct timer_rand_state)); | ||
936 | disk->random = state; | 933 | disk->random = state; |
937 | } | ||
938 | } | 934 | } |
939 | #endif | 935 | #endif |
940 | 936 | ||
@@ -1469,7 +1465,6 @@ late_initcall(seqgen_init); | |||
1469 | __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, | 1465 | __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, |
1470 | __be16 sport, __be16 dport) | 1466 | __be16 sport, __be16 dport) |
1471 | { | 1467 | { |
1472 | struct timeval tv; | ||
1473 | __u32 seq; | 1468 | __u32 seq; |
1474 | __u32 hash[12]; | 1469 | __u32 hash[12]; |
1475 | struct keydata *keyptr = get_keyptr(); | 1470 | struct keydata *keyptr = get_keyptr(); |
@@ -1485,8 +1480,7 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, | |||
1485 | seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; | 1480 | seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; |
1486 | seq += keyptr->count; | 1481 | seq += keyptr->count; |
1487 | 1482 | ||
1488 | do_gettimeofday(&tv); | 1483 | seq += ktime_get_real().tv64; |
1489 | seq += tv.tv_usec + tv.tv_sec * 1000000; | ||
1490 | 1484 | ||
1491 | return seq; | 1485 | return seq; |
1492 | } | 1486 | } |
@@ -1521,7 +1515,6 @@ __u32 secure_ip_id(__be32 daddr) | |||
1521 | __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | 1515 | __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, |
1522 | __be16 sport, __be16 dport) | 1516 | __be16 sport, __be16 dport) |
1523 | { | 1517 | { |
1524 | struct timeval tv; | ||
1525 | __u32 seq; | 1518 | __u32 seq; |
1526 | __u32 hash[4]; | 1519 | __u32 hash[4]; |
1527 | struct keydata *keyptr = get_keyptr(); | 1520 | struct keydata *keyptr = get_keyptr(); |
@@ -1543,12 +1536,11 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | |||
1543 | * As close as possible to RFC 793, which | 1536 | * As close as possible to RFC 793, which |
1544 | * suggests using a 250 kHz clock. | 1537 | * suggests using a 250 kHz clock. |
1545 | * Further reading shows this assumes 2 Mb/s networks. | 1538 | * Further reading shows this assumes 2 Mb/s networks. |
1546 | * For 10 Mb/s Ethernet, a 1 MHz clock is appropriate. | 1539 | * For 10 Gb/s Ethernet, a 1 GHz clock is appropriate. |
1547 | * That's funny, Linux has one built in! Use it! | 1540 | * That's funny, Linux has one built in! Use it! |
1548 | * (Networks are faster now - should this be increased?) | 1541 | * (Networks are faster now - should this be increased?) |
1549 | */ | 1542 | */ |
1550 | do_gettimeofday(&tv); | 1543 | seq += ktime_get_real().tv64; |
1551 | seq += tv.tv_usec + tv.tv_sec * 1000000; | ||
1552 | #if 0 | 1544 | #if 0 |
1553 | printk("init_seq(%lx, %lx, %d, %d) = %d\n", | 1545 | printk("init_seq(%lx, %lx, %d, %d) = %d\n", |
1554 | saddr, daddr, sport, dport, seq); | 1546 | saddr, daddr, sport, dport, seq); |
@@ -1556,8 +1548,6 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | |||
1556 | return seq; | 1548 | return seq; |
1557 | } | 1549 | } |
1558 | 1550 | ||
1559 | EXPORT_SYMBOL(secure_tcp_sequence_number); | ||
1560 | |||
1561 | /* Generate secure starting point for ephemeral IPV4 transport port search */ | 1551 | /* Generate secure starting point for ephemeral IPV4 transport port search */ |
1562 | u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport) | 1552 | u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport) |
1563 | { | 1553 | { |
@@ -1598,7 +1588,6 @@ u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, __be16 | |||
1598 | u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, | 1588 | u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, |
1599 | __be16 sport, __be16 dport) | 1589 | __be16 sport, __be16 dport) |
1600 | { | 1590 | { |
1601 | struct timeval tv; | ||
1602 | u64 seq; | 1591 | u64 seq; |
1603 | __u32 hash[4]; | 1592 | __u32 hash[4]; |
1604 | struct keydata *keyptr = get_keyptr(); | 1593 | struct keydata *keyptr = get_keyptr(); |
@@ -1611,8 +1600,7 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, | |||
1611 | seq = half_md4_transform(hash, keyptr->secret); | 1600 | seq = half_md4_transform(hash, keyptr->secret); |
1612 | seq |= ((u64)keyptr->count) << (32 - HASH_BITS); | 1601 | seq |= ((u64)keyptr->count) << (32 - HASH_BITS); |
1613 | 1602 | ||
1614 | do_gettimeofday(&tv); | 1603 | seq += ktime_get_real().tv64; |
1615 | seq += tv.tv_usec + tv.tv_sec * 1000000; | ||
1616 | seq &= (1ull << 48) - 1; | 1604 | seq &= (1ull << 48) - 1; |
1617 | #if 0 | 1605 | #if 0 |
1618 | printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n", | 1606 | printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n", |