random: remove variable limit
The variable limit was used to identify the nonblocking pool's unlimited random number generation. As the nonblocking pool is a thing of the past, remove the limit variable and any conditions around it (i.e. preserve the branches for limit == 1). Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
2e03c36f25
commit
43d8a72cd9
|
@ -466,7 +466,6 @@ struct entropy_store {
|
||||||
int entropy_count;
|
int entropy_count;
|
||||||
int entropy_total;
|
int entropy_total;
|
||||||
unsigned int initialized:1;
|
unsigned int initialized:1;
|
||||||
unsigned int limit:1;
|
|
||||||
unsigned int last_data_init:1;
|
unsigned int last_data_init:1;
|
||||||
__u8 last_data[EXTRACT_SIZE];
|
__u8 last_data[EXTRACT_SIZE];
|
||||||
};
|
};
|
||||||
|
@ -484,7 +483,6 @@ static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
|
||||||
static struct entropy_store input_pool = {
|
static struct entropy_store input_pool = {
|
||||||
.poolinfo = &poolinfo_table[0],
|
.poolinfo = &poolinfo_table[0],
|
||||||
.name = "input",
|
.name = "input",
|
||||||
.limit = 1,
|
|
||||||
.lock = __SPIN_LOCK_UNLOCKED(input_pool.lock),
|
.lock = __SPIN_LOCK_UNLOCKED(input_pool.lock),
|
||||||
.pool = input_pool_data
|
.pool = input_pool_data
|
||||||
};
|
};
|
||||||
|
@ -492,7 +490,6 @@ static struct entropy_store input_pool = {
|
||||||
static struct entropy_store blocking_pool = {
|
static struct entropy_store blocking_pool = {
|
||||||
.poolinfo = &poolinfo_table[1],
|
.poolinfo = &poolinfo_table[1],
|
||||||
.name = "blocking",
|
.name = "blocking",
|
||||||
.limit = 1,
|
|
||||||
.pull = &input_pool,
|
.pull = &input_pool,
|
||||||
.lock = __SPIN_LOCK_UNLOCKED(blocking_pool.lock),
|
.lock = __SPIN_LOCK_UNLOCKED(blocking_pool.lock),
|
||||||
.pool = blocking_pool_data,
|
.pool = blocking_pool_data,
|
||||||
|
@ -1212,15 +1209,6 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
|
||||||
r->entropy_count > r->poolinfo->poolfracbits)
|
r->entropy_count > r->poolinfo->poolfracbits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (r->limit == 0 && random_min_urandom_seed) {
|
|
||||||
unsigned long now = jiffies;
|
|
||||||
|
|
||||||
if (time_before(now,
|
|
||||||
r->last_pulled + random_min_urandom_seed * HZ))
|
|
||||||
return;
|
|
||||||
r->last_pulled = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
_xfer_secondary_pool(r, nbytes);
|
_xfer_secondary_pool(r, nbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1228,8 +1216,6 @@ static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
|
||||||
{
|
{
|
||||||
__u32 tmp[OUTPUT_POOL_WORDS];
|
__u32 tmp[OUTPUT_POOL_WORDS];
|
||||||
|
|
||||||
/* For /dev/random's pool, always leave two wakeups' worth */
|
|
||||||
int rsvd_bytes = r->limit ? 0 : random_read_wakeup_bits / 4;
|
|
||||||
int bytes = nbytes;
|
int bytes = nbytes;
|
||||||
|
|
||||||
/* pull at least as much as a wakeup */
|
/* pull at least as much as a wakeup */
|
||||||
|
@ -1240,7 +1226,7 @@ static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
|
||||||
trace_xfer_secondary_pool(r->name, bytes * 8, nbytes * 8,
|
trace_xfer_secondary_pool(r->name, bytes * 8, nbytes * 8,
|
||||||
ENTROPY_BITS(r), ENTROPY_BITS(r->pull));
|
ENTROPY_BITS(r), ENTROPY_BITS(r->pull));
|
||||||
bytes = extract_entropy(r->pull, tmp, bytes,
|
bytes = extract_entropy(r->pull, tmp, bytes,
|
||||||
random_read_wakeup_bits / 8, rsvd_bytes);
|
random_read_wakeup_bits / 8, 0);
|
||||||
mix_pool_bytes(r, tmp, bytes);
|
mix_pool_bytes(r, tmp, bytes);
|
||||||
credit_entropy_bits(r, bytes*8);
|
credit_entropy_bits(r, bytes*8);
|
||||||
}
|
}
|
||||||
|
@ -1268,7 +1254,7 @@ static void push_to_pool(struct work_struct *work)
|
||||||
static size_t account(struct entropy_store *r, size_t nbytes, int min,
|
static size_t account(struct entropy_store *r, size_t nbytes, int min,
|
||||||
int reserved)
|
int reserved)
|
||||||
{
|
{
|
||||||
int entropy_count, orig;
|
int entropy_count, orig, have_bytes;
|
||||||
size_t ibytes, nfrac;
|
size_t ibytes, nfrac;
|
||||||
|
|
||||||
BUG_ON(r->entropy_count > r->poolinfo->poolfracbits);
|
BUG_ON(r->entropy_count > r->poolinfo->poolfracbits);
|
||||||
|
@ -1277,14 +1263,12 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
|
||||||
retry:
|
retry:
|
||||||
entropy_count = orig = ACCESS_ONCE(r->entropy_count);
|
entropy_count = orig = ACCESS_ONCE(r->entropy_count);
|
||||||
ibytes = nbytes;
|
ibytes = nbytes;
|
||||||
/* If limited, never pull more than available */
|
/* never pull more than available */
|
||||||
if (r->limit) {
|
have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
|
||||||
int have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
|
|
||||||
|
|
||||||
if ((have_bytes -= reserved) < 0)
|
if ((have_bytes -= reserved) < 0)
|
||||||
have_bytes = 0;
|
have_bytes = 0;
|
||||||
ibytes = min_t(size_t, ibytes, have_bytes);
|
ibytes = min_t(size_t, ibytes, have_bytes);
|
||||||
}
|
|
||||||
if (ibytes < min)
|
if (ibytes < min)
|
||||||
ibytes = 0;
|
ibytes = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue