@@ -96,8 +96,8 @@ MODULE_PARM_DESC(ratelimit_disable, "Disable random ratelimit suppression");
96
96
/*
97
97
* Returns whether or not the input pool has been seeded and thus guaranteed
98
98
* to supply cryptographically secure random numbers. This applies to: the
99
- * /dev/urandom device, the get_random_bytes function, and the get_random_{u32 ,
100
- * ,u64,int,long} family of functions.
99
+ * /dev/urandom device, the get_random_bytes function, and the get_random_{u8 ,
100
+ * u16,u32 ,u64,int,long} family of functions.
101
101
*
102
102
* Returns: true if the input pool has been seeded.
103
103
* false if the input pool has not been seeded.
@@ -119,9 +119,9 @@ static void try_to_generate_entropy(void);
119
119
/*
120
120
* Wait for the input pool to be seeded and thus guaranteed to supply
121
121
* cryptographically secure random numbers. This applies to: the /dev/urandom
122
- * device, the get_random_bytes function, and the get_random_{u32,u64,int,long}
123
- * family of functions. Using any of these functions without first calling
124
- * this function forfeits the guarantee of security.
122
+ * device, the get_random_bytes function, and the get_random_{u8,u16, u32,u64,
123
+ * int,long} family of functions. Using any of these functions without first
124
+ * calling this function forfeits the guarantee of security.
125
125
*
126
126
* Returns: 0 if the input pool has been seeded.
127
127
* -ERESTARTSYS if the function was interrupted by a signal.
@@ -157,17 +157,19 @@ EXPORT_SYMBOL(wait_for_random_bytes);
157
157
* There are a few exported interfaces for use by other drivers:
158
158
*
159
159
* void get_random_bytes(void *buf, size_t len)
160
+ * u8 get_random_u8()
161
+ * u16 get_random_u16()
160
162
* u32 get_random_u32()
161
163
* u64 get_random_u64()
162
164
* unsigned int get_random_int()
163
165
* unsigned long get_random_long()
164
166
*
165
167
* These interfaces will return the requested number of random bytes
166
168
* into the given buffer or as a return value. This is equivalent to
167
- * a read from /dev/urandom. The u32, u64, int, and long family of
168
- * functions may be higher performance for one-off random integers,
169
- * because they do a bit of buffering and do not invoke reseeding
170
- * until the buffer is emptied.
169
+ * a read from /dev/urandom. The u8, u16, u32, u64, int, and long
170
+ * family of functions may be higher performance for one-off random
171
+ * integers, because they do a bit of buffering and do not invoke
172
+ * reseeding until the buffer is emptied.
171
173
*
172
174
*********************************************************************/
173
175
@@ -504,10 +506,10 @@ type get_random_ ##type(void) \
504
506
} \
505
507
EXPORT_SYMBOL(get_random_ ##type);
506
508
507
- DEFINE_BATCHED_ENTROPY (u64 )
508
- DEFINE_BATCHED_ENTROPY (u32 )
509
- DEFINE_BATCHED_ENTROPY (u16 )
510
509
DEFINE_BATCHED_ENTROPY (u8 )
510
+ DEFINE_BATCHED_ENTROPY (u16 )
511
+ DEFINE_BATCHED_ENTROPY (u32 )
512
+ DEFINE_BATCHED_ENTROPY (u64 )
511
513
512
514
#ifdef CONFIG_SMP
513
515
/*
@@ -522,6 +524,8 @@ int __cold random_prepare_cpu(unsigned int cpu)
522
524
* randomness.
523
525
*/
524
526
per_cpu_ptr (& crngs , cpu )-> generation = ULONG_MAX ;
527
+ per_cpu_ptr (& batched_entropy_u8 , cpu )-> position = UINT_MAX ;
528
+ per_cpu_ptr (& batched_entropy_u16 , cpu )-> position = UINT_MAX ;
525
529
per_cpu_ptr (& batched_entropy_u32 , cpu )-> position = UINT_MAX ;
526
530
per_cpu_ptr (& batched_entropy_u64 , cpu )-> position = UINT_MAX ;
527
531
return 0 ;
0 commit comments