Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
r->entropy_count > r->poolinfo->poolfracbits)
return;

if (r->limit == 0 && random_min_urandom_seed) {
if (r->limit == 0 && r->initialized && random_min_urandom_seed) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment for this? I'm not quite sure I can follow the logic of this function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called before extracting entropy from a pool, in order to move entropy from the "input" pool into the desired pool.

In order to prevent /dev/urandom from starving /dev/random, urandom will only reseed from the input pool once ever 60s (by default, it's tunable). This conditional block implements that ratelimit.

However, if it hasn't been initialized yet (doesn't have at least 128 bits of entropy), we should still greedily grab entropy until it has been, which is what my change does. My rationale is that we won't risk long-term starvation, since we'll only need to suck ~128 bits out, ever, and that ensuring the validity of the randomness in /dev/urandom ASAP is more important than keeping a few extra bits around to replenish /dev/urandom

Which part of that would help you as a comment? :) I don't think that entire graf merits inclusion…

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the highest of high levels. perhaps: "Only attempt to rate limit
transfers of entropy if we're initialized. Until we are initialized it
makes sense to transfer all the entropy we can."

On Tue, Jun 14, 2016 at 6:58 PM, Nelson Elhage [email protected]
wrote:

In drivers/char/random.c
#2 (comment):

@@ -981,7 +981,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
r->entropy_count > r->poolinfo->poolfracbits)
return;

  • if (r->limit == 0 && random_min_urandom_seed) {
  • if (r->limit == 0 && r->initialized && random_min_urandom_seed) {

This function is called before extracting entropy from a pool, in order to
move entropy from the "input" pool into the desired pool.

In order to prevent /dev/urandom from starving /dev/random, urandom will
only reseed from the input pool once ever 60s (by default, it's tunable).
This conditional block implements that ratelimit.

However, if it hasn't been initialized yet (doesn't have at least 128 bits
of entropy), we should still greedily grab entropy until it has been, which
is what my change does. My rationale is that we won't risk long-term
starvation, since we'll only need to suck ~128 bits out, ever, and that
ensuring the validity of the randomness in /dev/urandom ASAP is more
important than keeping a few extra bits around to replenish /dev/urandom

Which part of that would help you as a comment? :) I don't think that
entire graf merits inclusion…


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/alex/linux/pull/2/files/a631989af02a2737f5c00e2bd0358ca83915db74#r67073230,
or mute the thread
https://github.com/notifications/unsubscribe/AAADBNBF92iy1E0pDvi6JjWWhOmFb8yUks5qLzIIgaJpZM4I10Ca
.

"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: D1B3 ADC0 E023 8CA6

unsigned long now = jiffies;

if (time_before(now,
Expand Down