Skip to content

Commit 43d8a72

Browse files
smuellerDDtytso
authored andcommitted
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>
1 parent 2e03c36 commit 43d8a72

1 file changed

Lines changed: 7 additions & 23 deletions

File tree

‎drivers/char/random.c‎

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ struct entropy_store {
466466
int entropy_count;
467467
int entropy_total;
468468
unsigned int initialized:1;
469-
unsigned int limit:1;
470469
unsigned int last_data_init:1;
471470
__u8 last_data[EXTRACT_SIZE];
472471
};
@@ -484,15 +483,13 @@ static __u32 blocking_pool_data[OUTPUT_POOL_WORDS] __latent_entropy;
484483
static struct entropy_store input_pool = {
485484
.poolinfo = &poolinfo_table[0],
486485
.name = "input",
487-
.limit = 1,
488486
.lock = __SPIN_LOCK_UNLOCKED(input_pool.lock),
489487
.pool = input_pool_data
490488
};
491489

492490
static struct entropy_store blocking_pool = {
493491
.poolinfo = &poolinfo_table[1],
494492
.name = "blocking",
495-
.limit = 1,
496493
.pull = &input_pool,
497494
.lock = __SPIN_LOCK_UNLOCKED(blocking_pool.lock),
498495
.pool = blocking_pool_data,
@@ -1212,24 +1209,13 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
12121209
r->entropy_count > r->poolinfo->poolfracbits)
12131210
return;
12141211

1215-
if (r->limit == 0 && random_min_urandom_seed) {
1216-
unsigned long now = jiffies;
1217-
1218-
if (time_before(now,
1219-
r->last_pulled + random_min_urandom_seed * HZ))
1220-
return;
1221-
r->last_pulled = now;
1222-
}
1223-
12241212
_xfer_secondary_pool(r, nbytes);
12251213
}
12261214

12271215
static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
12281216
{
12291217
__u32 tmp[OUTPUT_POOL_WORDS];
12301218

1231-
/* For /dev/random's pool, always leave two wakeups' worth */
1232-
int rsvd_bytes = r->limit ? 0 : random_read_wakeup_bits / 4;
12331219
int bytes = nbytes;
12341220

12351221
/* pull at least as much as a wakeup */
@@ -1240,7 +1226,7 @@ static void _xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
12401226
trace_xfer_secondary_pool(r->name, bytes * 8, nbytes * 8,
12411227
ENTROPY_BITS(r), ENTROPY_BITS(r->pull));
12421228
bytes = extract_entropy(r->pull, tmp, bytes,
1243-
random_read_wakeup_bits / 8, rsvd_bytes);
1229+
random_read_wakeup_bits / 8, 0);
12441230
mix_pool_bytes(r, tmp, bytes);
12451231
credit_entropy_bits(r, bytes*8);
12461232
}
@@ -1268,7 +1254,7 @@ static void push_to_pool(struct work_struct *work)
12681254
static size_t account(struct entropy_store *r, size_t nbytes, int min,
12691255
int reserved)
12701256
{
1271-
int entropy_count, orig;
1257+
int entropy_count, orig, have_bytes;
12721258
size_t ibytes, nfrac;
12731259

12741260
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,
12771263
retry:
12781264
entropy_count = orig = ACCESS_ONCE(r->entropy_count);
12791265
ibytes = nbytes;
1280-
/* If limited, never pull more than available */
1281-
if (r->limit) {
1282-
int have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
1266+
/* never pull more than available */
1267+
have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
12831268

1284-
if ((have_bytes -= reserved) < 0)
1285-
have_bytes = 0;
1286-
ibytes = min_t(size_t, ibytes, have_bytes);
1287-
}
1269+
if ((have_bytes -= reserved) < 0)
1270+
have_bytes = 0;
1271+
ibytes = min_t(size_t, ibytes, have_bytes);
12881272
if (ibytes < min)
12891273
ibytes = 0;
12901274

0 commit comments

Comments
 (0)