@@ -456,7 +456,7 @@ static DEFINE_SPINLOCK(random_ready_list_lock);
456456static LIST_HEAD (random_ready_list );
457457
458458struct crng_state {
459- __u32 state [16 ];
459+ u32 state [16 ];
460460 unsigned long init_time ;
461461 spinlock_t lock ;
462462};
@@ -483,9 +483,9 @@ static bool crng_need_final_init = false;
483483static int crng_init_cnt = 0 ;
484484static unsigned long crng_global_init_time = 0 ;
485485#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 ]);
487487static void _crng_backtrack_protect (struct crng_state * crng ,
488- __u8 tmp [CHACHA_BLOCK_SIZE ], int used );
488+ u8 tmp [CHACHA_BLOCK_SIZE ], int used );
489489static void process_random_ready_list (void );
490490static void _get_random_bytes (void * buf , int nbytes );
491491
@@ -509,16 +509,16 @@ MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression");
509509struct entropy_store ;
510510struct entropy_store {
511511 /* read-only data: */
512- __u32 * pool ;
512+ u32 * pool ;
513513 const char * name ;
514514
515515 /* read-write data: */
516516 spinlock_t lock ;
517- unsigned short add_ptr ;
518- unsigned short input_rotate ;
517+ u16 add_ptr ;
518+ u16 input_rotate ;
519519 int entropy_count ;
520520 unsigned int last_data_init :1 ;
521- __u8 last_data [EXTRACT_SIZE ];
521+ u8 last_data [EXTRACT_SIZE ];
522522};
523523
524524static 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,
527527 size_t nbytes , int fips );
528528
529529static 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 ;
531531
532532static struct entropy_store input_pool = {
533533 .name = "input" ,
534534 .lock = __SPIN_LOCK_UNLOCKED (input_pool .lock ),
535535 .pool = input_pool_data
536536};
537537
538- static __u32 const twist_table [8 ] = {
538+ static u32 const twist_table [8 ] = {
539539 0x00000000 , 0x3b6e20c8 , 0x76dc4190 , 0x4db26158 ,
540540 0xedb88320 , 0xd6d6a3e8 , 0x9b64c2b0 , 0xa00ae278 };
541541
@@ -554,8 +554,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
554554{
555555 unsigned long i ;
556556 int input_rotate ;
557- const unsigned char * bytes = in ;
558- __u32 w ;
557+ const u8 * bytes = in ;
558+ u32 w ;
559559
560560 input_rotate = r -> input_rotate ;
561561 i = r -> add_ptr ;
@@ -608,10 +608,10 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in,
608608}
609609
610610struct fast_pool {
611- __u32 pool [4 ];
611+ u32 pool [4 ];
612612 unsigned long last ;
613- unsigned short reg_idx ;
614- unsigned char count ;
613+ u16 reg_idx ;
614+ u8 count ;
615615};
616616
617617/*
@@ -621,8 +621,8 @@ struct fast_pool {
621621 */
622622static void fast_mix (struct fast_pool * f )
623623{
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 ];
626626
627627 a += b ; c += d ;
628628 b = rol32 (b , 6 ); d = rol32 (d , 27 );
@@ -814,14 +814,14 @@ static bool __init crng_init_try_arch_early(struct crng_state *crng)
814814static void crng_initialize_secondary (struct crng_state * crng )
815815{
816816 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 );
818818 crng_init_try_arch (crng );
819819 crng -> init_time = jiffies - CRNG_RESEED_INTERVAL - 1 ;
820820}
821821
822822static void __init crng_initialize_primary (struct crng_state * crng )
823823{
824- _extract_entropy (& input_pool , & crng -> state [4 ], sizeof (__u32 ) * 12 , 0 );
824+ _extract_entropy (& input_pool , & crng -> state [4 ], sizeof (u32 ) * 12 , 0 );
825825 if (crng_init_try_arch_early (crng ) && trust_cpu && crng_init < 2 ) {
826826 invalidate_batched_entropy ();
827827 numa_crng_init ();
@@ -911,10 +911,10 @@ static struct crng_state *select_crng(void)
911911 * path. So we can't afford to dilly-dally. Returns the number of
912912 * bytes processed from cp.
913913 */
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 )
915915{
916916 unsigned long flags ;
917- char * p ;
917+ u8 * p ;
918918 size_t ret = 0 ;
919919
920920 if (!spin_trylock_irqsave (& primary_crng .lock , flags ))
@@ -923,7 +923,7 @@ static size_t crng_fast_load(const char *cp, size_t len)
923923 spin_unlock_irqrestore (& primary_crng .lock , flags );
924924 return 0 ;
925925 }
926- p = (unsigned char * ) & primary_crng .state [4 ];
926+ p = (u8 * ) & primary_crng .state [4 ];
927927 while (len > 0 && crng_init_cnt < CRNG_INIT_CNT_THRESH ) {
928928 p [crng_init_cnt % CHACHA_KEY_SIZE ] ^= * cp ;
929929 cp ++ ; crng_init_cnt ++ ; len -- ; ret ++ ;
@@ -951,14 +951,14 @@ static size_t crng_fast_load(const char *cp, size_t len)
951951 * like a fixed DMI table (for example), which might very well be
952952 * unique to the machine, but is otherwise unvarying.
953953 */
954- static int crng_slow_load (const char * cp , size_t len )
954+ static int crng_slow_load (const u8 * cp , size_t len )
955955{
956956 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 ];
962962
963963 if (!spin_trylock_irqsave (& primary_crng .lock , flags ))
964964 return 0 ;
@@ -987,8 +987,8 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
987987 unsigned long flags ;
988988 int i , num ;
989989 union {
990- __u8 block [CHACHA_BLOCK_SIZE ];
991- __u32 key [8 ];
990+ u8 block [CHACHA_BLOCK_SIZE ];
991+ u32 key [8 ];
992992 } buf ;
993993
994994 if (r ) {
@@ -1015,7 +1015,7 @@ static void crng_reseed(struct crng_state *crng, struct entropy_store *r)
10151015}
10161016
10171017static void _extract_crng (struct crng_state * crng ,
1018- __u8 out [CHACHA_BLOCK_SIZE ])
1018+ u8 out [CHACHA_BLOCK_SIZE ])
10191019{
10201020 unsigned long flags , init_time ;
10211021
@@ -1033,7 +1033,7 @@ static void _extract_crng(struct crng_state *crng,
10331033 spin_unlock_irqrestore (& crng -> lock , flags );
10341034}
10351035
1036- static void extract_crng (__u8 out [CHACHA_BLOCK_SIZE ])
1036+ static void extract_crng (u8 out [CHACHA_BLOCK_SIZE ])
10371037{
10381038 _extract_crng (select_crng (), out );
10391039}
@@ -1043,34 +1043,34 @@ static void extract_crng(__u8 out[CHACHA_BLOCK_SIZE])
10431043 * enough) to mutate the CRNG key to provide backtracking protection.
10441044 */
10451045static void _crng_backtrack_protect (struct crng_state * crng ,
1046- __u8 tmp [CHACHA_BLOCK_SIZE ], int used )
1046+ u8 tmp [CHACHA_BLOCK_SIZE ], int used )
10471047{
10481048 unsigned long flags ;
1049- __u32 * s , * d ;
1049+ u32 * s , * d ;
10501050 int i ;
10511051
1052- used = round_up (used , sizeof (__u32 ));
1052+ used = round_up (used , sizeof (u32 ));
10531053 if (used + CHACHA_KEY_SIZE > CHACHA_BLOCK_SIZE ) {
10541054 extract_crng (tmp );
10551055 used = 0 ;
10561056 }
10571057 spin_lock_irqsave (& crng -> lock , flags );
1058- s = (__u32 * ) & tmp [used ];
1058+ s = (u32 * ) & tmp [used ];
10591059 d = & crng -> state [4 ];
10601060 for (i = 0 ; i < 8 ; i ++ )
10611061 * d ++ ^= * s ++ ;
10621062 spin_unlock_irqrestore (& crng -> lock , flags );
10631063}
10641064
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 )
10661066{
10671067 _crng_backtrack_protect (select_crng (), tmp , used );
10681068}
10691069
10701070static ssize_t extract_crng_user (void __user * buf , size_t nbytes )
10711071{
10721072 ssize_t ret = 0 , i = CHACHA_BLOCK_SIZE ;
1073- __u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
1073+ u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
10741074 int large_request = (nbytes > 256 );
10751075
10761076 while (nbytes ) {
@@ -1158,8 +1158,8 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
11581158 struct entropy_store * r ;
11591159 struct {
11601160 long jiffies ;
1161- unsigned cycles ;
1162- unsigned num ;
1161+ unsigned int cycles ;
1162+ unsigned int num ;
11631163 } sample ;
11641164 long delta , delta2 , delta3 ;
11651165
@@ -1241,15 +1241,15 @@ static void add_interrupt_bench(cycles_t start)
12411241#define add_interrupt_bench (x )
12421242#endif
12431243
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 )
12451245{
1246- __u32 * ptr = (__u32 * ) regs ;
1246+ u32 * ptr = (u32 * ) regs ;
12471247 unsigned int idx ;
12481248
12491249 if (regs == NULL )
12501250 return 0 ;
12511251 idx = READ_ONCE (f -> reg_idx );
1252- if (idx >= sizeof (struct pt_regs ) / sizeof (__u32 ))
1252+ if (idx >= sizeof (struct pt_regs ) / sizeof (u32 ))
12531253 idx = 0 ;
12541254 ptr += idx ++ ;
12551255 WRITE_ONCE (f -> reg_idx , idx );
@@ -1263,8 +1263,8 @@ void add_interrupt_randomness(int irq)
12631263 struct pt_regs * regs = get_irq_regs ();
12641264 unsigned long now = jiffies ;
12651265 cycles_t cycles = random_get_entropy ();
1266- __u32 c_high , j_high ;
1267- __u64 ip ;
1266+ u32 c_high , j_high ;
1267+ u64 ip ;
12681268
12691269 if (cycles == 0 )
12701270 cycles = get_reg (fast_pool , regs );
@@ -1282,8 +1282,7 @@ void add_interrupt_randomness(int irq)
12821282
12831283 if (unlikely (crng_init == 0 )) {
12841284 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 ) {
12871286 fast_pool -> count = 0 ;
12881287 fast_pool -> last = now ;
12891288 }
@@ -1380,7 +1379,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
13801379 *
13811380 * Note: we assume that .poolwords is a multiple of 16 words.
13821381 */
1383- static void extract_buf (struct entropy_store * r , __u8 * out )
1382+ static void extract_buf (struct entropy_store * r , u8 * out )
13841383{
13851384 struct blake2s_state state __aligned (__alignof__ (unsigned long ));
13861385 u8 hash [BLAKE2S_HASH_SIZE ];
@@ -1430,7 +1429,7 @@ static ssize_t _extract_entropy(struct entropy_store *r, void *buf,
14301429 size_t nbytes , int fips )
14311430{
14321431 ssize_t ret = 0 , i ;
1433- __u8 tmp [EXTRACT_SIZE ];
1432+ u8 tmp [EXTRACT_SIZE ];
14341433 unsigned long flags ;
14351434
14361435 while (nbytes ) {
@@ -1468,7 +1467,7 @@ static ssize_t _extract_entropy(struct entropy_store *r, void *buf,
14681467static ssize_t extract_entropy (struct entropy_store * r , void * buf ,
14691468 size_t nbytes , int min , int reserved )
14701469{
1471- __u8 tmp [EXTRACT_SIZE ];
1470+ u8 tmp [EXTRACT_SIZE ];
14721471 unsigned long flags ;
14731472
14741473 /* 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,
15301529 */
15311530static void _get_random_bytes (void * buf , int nbytes )
15321531{
1533- __u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
1532+ u8 tmp [CHACHA_BLOCK_SIZE ] __aligned (4 );
15341533
15351534 trace_get_random_bytes (nbytes , _RET_IP_ );
15361535
@@ -1724,7 +1723,7 @@ EXPORT_SYMBOL(del_random_ready_callback);
17241723int __must_check get_random_bytes_arch (void * buf , int nbytes )
17251724{
17261725 int left = nbytes ;
1727- char * p = buf ;
1726+ u8 * p = buf ;
17281727
17291728 trace_get_random_bytes_arch (left , _RET_IP_ );
17301729 while (left ) {
@@ -1866,7 +1865,7 @@ static int
18661865write_pool (struct entropy_store * r , const char __user * buffer , size_t count )
18671866{
18681867 size_t bytes ;
1869- __u32 t , buf [16 ];
1868+ u32 t , buf [16 ];
18701869 const char __user * p = buffer ;
18711870
18721871 while (count > 0 ) {
@@ -1876,7 +1875,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
18761875 if (copy_from_user (& buf , p , bytes ))
18771876 return - EFAULT ;
18781877
1879- for (b = bytes ; b > 0 ; b -= sizeof (__u32 ), i ++ ) {
1878+ for (b = bytes ; b > 0 ; b -= sizeof (u32 ), i ++ ) {
18801879 if (!arch_get_random_int (& t ))
18811880 break ;
18821881 buf [i ] ^= t ;
0 commit comments