Skip to content

Issue #4709 RFC: reseed task_rng#4885

Closed
cpeterso wants to merge 2 commits intorust-lang:incomingfrom
cpeterso:issue-4709-reseed-task-rng
Closed

Issue #4709 RFC: reseed task_rng#4885
cpeterso wants to merge 2 commits intorust-lang:incomingfrom
cpeterso:issue-4709-reseed-task-rng

Conversation

@cpeterso
Copy link
Contributor

@graydon for issue #4709.

The first change (commit 294b4a9) is straightforward. It adds a new isaac_reseed() function and uninlines isaac_seed() and isaac_init().

The second change (commit 2ef8a32) is more questionable. It adds a rust_sched_loop::idle() function, which is called when rust_sched_driver::start_main_loop() has no runnable tasks. idle() checks whether rctx has drained its entropy pool, i.e. generated more than 256 random uint32_ts. If not reseeded, rctx will be stirring the same entropy bits to generate new random numbers.

Possible improvements:

  • Add a minimum and/or maximum reseed frequency to idle(). For example, Schneier and Ferguson's Fortuna PRNG doesn't reseed more often 10 times per second.
  • Reseed less frequently than 256 random numbers (isaac's RANDSIZ)?
  • If Rust's task scheduler supported alarm tasks to be run after a specified timeout, they could be used for periodic cleanup work like reseeding the RNG.

This change also adds a fast path to rust_sched_loop::schedule_task() when there is only 1 runnable task to avoid depleting task_rng's precious entropy.

@brson
Copy link
Contributor

brson commented Feb 11, 2013

The second commit reseeds the scheduler's random number generator, which is probably desirable, but is not the same as the TLS generator mentioned in #4709. That rng is created by core::rand::task_rng.

@cpeterso
Copy link
Contributor Author

doh!

@cpeterso cpeterso closed this Feb 12, 2013
RalfJung added a commit to RalfJung/rust that referenced this pull request Mar 14, 2026
explain how to control target features with Miri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants