@@ -456,7 +456,7 @@ static DEFINE_SPINLOCK(random_ready_list_lock);
456
456
static LIST_HEAD (random_ready_list );
457
457
458
458
struct crng_state {
459
- __u32 state [16 ];
459
+ u32 state [16 ];
460
460
unsigned long init_time ;
461
461
spinlock_t lock ;
462
462
};
@@ -483,9 +483,9 @@ static bool crng_need_final_init = false;
483
483
static int crng_init_cnt = 0 ;
484
484
static unsigned long crng_global_init_time = 0 ;
485
485
#define CRNG_INIT_CNT_THRESH (2*CHACHA_KEY_SIZE)
486
- static void _extract_crng (struct crng_state * crng , __u8 out [CHACHA_BLOCK_SIZE ]);
486
+ static void _extract_crng (struct crng_state * crng , u8 out [CHACHA_BLOCK_SIZE ]);
487
487
static void _crng_backtrack_protect (struct crng_state * crng ,
488
- __u8 tmp [CHACHA_BLOCK_SIZE ], int used );
488
+ u8 tmp [CHACHA_BLOCK_SIZE ], int used );
489
489
static void process_random_ready_list (void );
490
490
static void _get_random_bytes (void * buf , int nbytes );
491
491
@@ -509,16 +509,16 @@ MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression");
509
509
struct entropy_store ;
510
510
struct entropy_store {
511
511
/* read-only data: */
512
- __u32 * pool ;
512
+ u32 * pool ;
513
513
const char * name ;
514
514
515
515
/* read-write data: */
516
516
spinlock_t lock ;
517
- unsigned short add_ptr ;
518
- unsigned short input_rotate ;
517
+ u16 add_ptr ;
518
+ u16 input_rotate ;
519
519
int entropy_count ;
520
520
unsigned int last_data_init :1 ;
521
- __u8 last_data [EXTRACT_SIZE ];
521
+ u8 last_data [EXTRACT_SIZE ];
522
522
};
523
523
524
524
static ssize_t extract_entropy (struct entropy_store * r , void * buf ,
@@ -527,15 +527,15 @@ static ssize_t _extract_entropy(struct entropy_store *r, void *buf,
527
527
size_t nbytes , int fips );
528
528
529
529
static void crng_reseed (struct crng_state * crng , struct entropy_store * r );
530
- static __u32 input_pool_data [INPUT_POOL_WORDS ] __latent_entropy ;
530
+ static u32 input_pool_data [INPUT_POOL_WORDS ] __latent_entropy ;
531
531
532
532
static struct entropy_store input_pool = {
533
533
.name = "input" ,
534
534
.lock = __SPIN_LOCK_UNLOCKED (input_pool .lock ),
535
535
.pool = input_pool_data
536
536
};
537
537
538
- static __u32 const twist_table [8 ] = {
538
+ static u32 const twist_table [8 ] = {
539
539
0x00000000 , 0x3b6e20c8 , 0x76dc4190 , 0x4db26158 ,
540
540
0xedb88320 , 0xd6d6a3e8 , 0x9b64c2b0 , 0xa00ae278 };
541
541
@@ -554,8 +554,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
554
554
{
555
555
unsigned long i ;
556
556
int input_rotate ;
557
- const unsigned char * bytes = in ;
558
- __u32 w ;
557
+ const u8 * bytes = in ;
558
+ u32 w ;
559
559
560
560
input_rotate = r -> input_rotate ;
561
561
i = r -> add_ptr ;
@@ -608,10 +608,10 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in,
608
608
}
609
609
610
610
struct fast_pool {
611
- __u32 pool [4 ];
611
+ u32 pool [4 ];
612
612
unsigned long last ;
613
- unsigned short reg_idx ;
614
- unsigned char count ;
613
+ u16 reg_idx ;
614
+ u8 count ;
615
615
};
616
616
617
617
/*
@@ -621,8 +621,8 @@ struct fast_pool {
621
621
*/
622
622
static void fast_mix (struct fast_pool * f )
623
623
{
624
- __u32 a = f -> pool [0 ], b = f -> pool [1 ];
625
- __u32 c = f -> pool [2 ], d = f -> pool [3 ];
624
+ u32 a = f -> pool [0 ], b = f -> pool [1 ];
625
+ u32 c = f -> pool [2 ], d = f -> pool [3 ];
626
626
627
627
a += b ; c += d ;
628
628
b = rol32 (b , 6 ); d = rol32 (d , 27 );
@@ -814,14 +814,14 @@ static bool __init crng_init_try_arch_early(struct crng_state *crng)
814
814
static void crng_initialize_secondary (struct crng_state * crng )
815
815
{
816
816
chacha_init_consts (crng -> state );
817
- _get_random_bytes (& crng -> state [4 ], sizeof (__u32 ) * 12 );
817
+ _get_random_bytes (& crng -> state [4 ], sizeof (u32 ) * 12 );
818
818
crng_init_try_arch (crng );
819
819
crng -> init_time = jiffies - CRNG_RESEED_INTERVAL - 1 ;
820
820
}
821
821
822
822
static void __init crng_initialize_primary (struct crng_state * crng )
823
823
{
824
- _extract_entropy (& input_pool , & crng -> state [4 ], sizeof (__u32 ) * 12 , 0 );
824
+ _extract_entropy (& input_pool , & crng -> state [4 ], sizeof (u32 ) * 12 , 0 );
825
825
if (crng_init_try_arch_early (crng ) && trust_cpu && crng_init < 2 ) {
826
826
invalidate_batched_entropy ();
827
827
numa_crng_init ();
@@ -911,10 +911,10 @@ static struct crng_state *select_crng(void)
911
911
* path. So we can't afford to dilly-dally. Returns the number of
912
912
* bytes processed from cp.
913
913
*/
914
- static size_t crng_fast_load (const char * cp , size_t len )
914
+ static size_t crng_fast_load (const u8 * cp , size_t len )
915
915
{
916
916
unsigned long flags ;
917
- char * p ;
917
+ u8 * p ;
918
918
size_t ret = 0 ;
919
919
920
920
if (!spin_trylock_irqsave (& primary_crng .lock , flags ))
@@ -923,7 +923,7 @@ static size_t crng_fast_load(const char *cp, size_t len)
923
923
spin_unlock_irqrestore (& primary_crng .lock , flags );
924
924
return 0 ;
925
925
}
926
- p = (unsigned char * ) & primary_crng .state [4 ];
926
+ p = (u8 * ) & primary_crng .state [4 ];
927
927
while (len > 0 && crng_init_cnt < CRNG_INIT_CNT_THRESH ) {
928
928
p [crng_init_cnt % CHACHA_KEY_SIZE ] ^= * cp ;
929
929
cp ++ ; crng_init_cnt ++ ; len -- ; ret ++ ;
@@ -951,14 +951,14 @@ static size_t crng_fast_load(const char *cp, size_t len)
951
951
* like a fixed DMI table (for example), which might very well be
952
952
* unique to the machine, but is otherwise unvarying.
953
953
*/
954
- static int crng_slow_load (const char * cp , size_t len )
954
+ static int crng_slow_load (const u8 * cp , size_t len )
955
955
{
956
956
unsigned long flags ;
957
- static unsigned char lfsr = 1 ;
958
- unsigned char tmp ;
959
- unsigned i , max = CHACHA_KEY_SIZE ;
960
- const char * src_buf = cp ;
961
- char * dest_buf = (char * ) & primary_crng .state [4 ];
957
+ static u8 lfsr = 1 ;
958
+ u8 tmp ;
959
+ unsigned int i , max = CHACHA_KEY_SIZE ;
960
+ const u8 * src_buf = cp ;
961
+ u8 * dest_buf = (u8 * ) & primary_crng .state [4 ];
962
962
963
963
if (!spin_trylock_irqsave (& primary_crng .lock , flags ))
964
964
return 0 ;
@@ -987,8 +987,8 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
987
987
unsigned long flags ;
988
988
int i , num ;
989
989
union {
990
- __u8 block [CHACHA_BLOCK_SIZE ];
991
- __u32 key [8 ];
990
+ u8 block [CHACHA_BLOCK_SIZE ];
991
+ u32 key [8 ];
992
992
} buf ;
993
993
994
994
if (r ) {
@@ -1015,7 +1015,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
1015
1015
}
1016
1016
1017
1017
static void _extract_crng (struct crng_state * crng ,
1018
- __u8 out [CHACHA_BLOCK_SIZE ])
1018
+ u8 out [CHACHA_BLOCK_SIZE ])
1019
1019
{
1020
1020
unsigned long flags , init_time ;
1021
1021
@@ -1033,7 +1033,7 @@ static void _extract_crng(struct crng_state *crng,
1033
1033
spin_unlock_irqrestore (& crng -> lock , flags );
1034
1034
}
1035
1035
1036
- static void extract_crng (__u8 out [CHACHA_BLOCK_SIZE ])
1036
+ static void extract_crng (u8 out [CHACHA_BLOCK_SIZE ])
1037
1037
{
1038
1038
_extract_crng (select_crng (), out );
1039
1039
}
@@ -1043,34 +1043,34 @@ static void extract_crng(__u8 out[CHACHA_BLOCK_SIZE])
1043
1043
* enough) to mutate the CRNG key to provide backtracking protection.
1044
1044
*/
1045
1045
static void _crng_backtrack_protect (struct crng_state * crng ,
1046
- __u8 tmp [CHACHA_BLOCK_SIZE ], int used )
1046
+ u8 tmp [CHACHA_BLOCK_SIZE ], int used )
1047
1047
{
1048
1048
unsigned long flags ;
1049
- __u32 * s , * d ;
1049
+ u32 * s , * d ;
1050
1050
int i ;
1051
1051
1052
- used = round_up (used , sizeof (__u32 ));
1052
+ used = round_up (used , sizeof (u32 ));
1053
1053
if (used + CHACHA_KEY_SIZE > CHACHA_BLOCK_SIZE ) {
1054
1054
extract_crng (tmp );
1055
1055
used = 0 ;
1056
1056
}
1057
1057
spin_lock_irqsave (& crng -> lock , flags );
1058
- s = (__u32 * ) & tmp [used ];
1058
+ s = (u32 * ) & tmp [used ];
1059
1059
d = & crng -> state [4 ];
1060
1060
for (i = 0 ; i < 8 ; i ++ )
1061
1061
* d ++ ^= * s ++ ;
1062
1062
spin_unlock_irqrestore (& crng -> lock , flags );
1063
1063
}
1064
1064
1065
- static void crng_backtrack_protect (__u8 tmp [CHACHA_BLOCK_SIZE ], int used )
1065
+ static void crng_backtrack_protect (u8 tmp [CHACHA_BLOCK_SIZE ], int used )
1066
1066
{
1067
1067
_crng_backtrack_protect (select_crng (), tmp , used );
1068
1068
}
1069
1069
1070
1070
static ssize_t extract_crng_user (void __user * buf , size_t nbytes )
1071
1071
{
1072
1072
ssize_t ret = 0 , i = CHACHA_BLOCK_SIZE ;
1073
- __u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
1073
+ u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
1074
1074
int large_request = (nbytes > 256 );
1075
1075
1076
1076
while (nbytes ) {
@@ -1158,8 +1158,8 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
1158
1158
struct entropy_store * r ;
1159
1159
struct {
1160
1160
long jiffies ;
1161
- unsigned cycles ;
1162
- unsigned num ;
1161
+ unsigned int cycles ;
1162
+ unsigned int num ;
1163
1163
} sample ;
1164
1164
long delta , delta2 , delta3 ;
1165
1165
@@ -1241,15 +1241,15 @@ static void add_interrupt_bench(cycles_t start)
1241
1241
#define add_interrupt_bench (x )
1242
1242
#endif
1243
1243
1244
- static __u32 get_reg (struct fast_pool * f , struct pt_regs * regs )
1244
+ static u32 get_reg (struct fast_pool * f , struct pt_regs * regs )
1245
1245
{
1246
- __u32 * ptr = (__u32 * ) regs ;
1246
+ u32 * ptr = (u32 * ) regs ;
1247
1247
unsigned int idx ;
1248
1248
1249
1249
if (regs == NULL )
1250
1250
return 0 ;
1251
1251
idx = READ_ONCE (f -> reg_idx );
1252
- if (idx >= sizeof (struct pt_regs ) / sizeof (__u32 ))
1252
+ if (idx >= sizeof (struct pt_regs ) / sizeof (u32 ))
1253
1253
idx = 0 ;
1254
1254
ptr += idx ++ ;
1255
1255
WRITE_ONCE (f -> reg_idx , idx );
@@ -1263,8 +1263,8 @@ void add_interrupt_randomness(int irq)
1263
1263
struct pt_regs * regs = get_irq_regs ();
1264
1264
unsigned long now = jiffies ;
1265
1265
cycles_t cycles = random_get_entropy ();
1266
- __u32 c_high , j_high ;
1267
- __u64 ip ;
1266
+ u32 c_high , j_high ;
1267
+ u64 ip ;
1268
1268
1269
1269
if (cycles == 0 )
1270
1270
cycles = get_reg (fast_pool , regs );
@@ -1282,8 +1282,7 @@ void add_interrupt_randomness(int irq)
1282
1282
1283
1283
if (unlikely (crng_init == 0 )) {
1284
1284
if ((fast_pool -> count >= 64 ) &&
1285
- crng_fast_load ((char * ) fast_pool -> pool ,
1286
- sizeof (fast_pool -> pool )) > 0 ) {
1285
+ crng_fast_load ((u8 * )fast_pool -> pool , sizeof (fast_pool -> pool )) > 0 ) {
1287
1286
fast_pool -> count = 0 ;
1288
1287
fast_pool -> last = now ;
1289
1288
}
@@ -1380,7 +1379,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
1380
1379
*
1381
1380
* Note: we assume that .poolwords is a multiple of 16 words.
1382
1381
*/
1383
- static void extract_buf (struct entropy_store * r , __u8 * out )
1382
+ static void extract_buf (struct entropy_store * r , u8 * out )
1384
1383
{
1385
1384
struct blake2s_state state __aligned (__alignof__ (unsigned long ));
1386
1385
u8 hash [BLAKE2S_HASH_SIZE ];
@@ -1430,7 +1429,7 @@ static ssize_t _extract_entropy(struct entropy_store *r, void *buf,
1430
1429
size_t nbytes , int fips )
1431
1430
{
1432
1431
ssize_t ret = 0 , i ;
1433
- __u8 tmp [EXTRACT_SIZE ];
1432
+ u8 tmp [EXTRACT_SIZE ];
1434
1433
unsigned long flags ;
1435
1434
1436
1435
while (nbytes ) {
@@ -1468,7 +1467,7 @@ static ssize_t _extract_entropy(struct entropy_store *r, void *buf,
1468
1467
static ssize_t extract_entropy (struct entropy_store * r , void * buf ,
1469
1468
size_t nbytes , int min , int reserved )
1470
1469
{
1471
- __u8 tmp [EXTRACT_SIZE ];
1470
+ u8 tmp [EXTRACT_SIZE ];
1472
1471
unsigned long flags ;
1473
1472
1474
1473
/* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */
@@ -1530,7 +1529,7 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller,
1530
1529
*/
1531
1530
static void _get_random_bytes (void * buf , int nbytes )
1532
1531
{
1533
- __u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
1532
+ u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
1534
1533
1535
1534
trace_get_random_bytes (nbytes , _RET_IP_ );
1536
1535
@@ -1724,7 +1723,7 @@ EXPORT_SYMBOL(del_random_ready_callback);
1724
1723
int __must_check get_random_bytes_arch (void * buf , int nbytes )
1725
1724
{
1726
1725
int left = nbytes ;
1727
- char * p = buf ;
1726
+ u8 * p = buf ;
1728
1727
1729
1728
trace_get_random_bytes_arch (left , _RET_IP_ );
1730
1729
while (left ) {
@@ -1866,7 +1865,7 @@ static int
1866
1865
write_pool (struct entropy_store * r , const char __user * buffer , size_t count )
1867
1866
{
1868
1867
size_t bytes ;
1869
- __u32 t , buf [16 ];
1868
+ u32 t , buf [16 ];
1870
1869
const char __user * p = buffer ;
1871
1870
1872
1871
while (count > 0 ) {
@@ -1876,7 +1875,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1876
1875
if (copy_from_user (& buf , p , bytes ))
1877
1876
return - EFAULT ;
1878
1877
1879
- for (b = bytes ; b > 0 ; b -= sizeof (__u32 ), i ++ ) {
1878
+ for (b = bytes ; b > 0 ; b -= sizeof (u32 ), i ++ ) {
1880
1879
if (!arch_get_random_int (& t ))
1881
1880
break ;
1882
1881
buf [i ] ^= t ;
0 commit comments