Page MenuHomeFreeBSD

random: Exclude the timestamp from healthtest for pure sources
ClosedPublic

Authored by markj on Aug 28 2025, 9:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 11, 1:19 PM
Unknown Object (File)
Sat, Oct 11, 1:19 PM
Unknown Object (File)
Sat, Oct 11, 1:19 PM
Unknown Object (File)
Sat, Oct 11, 1:19 PM
Unknown Object (File)
Sat, Oct 11, 5:04 AM
Unknown Object (File)
Thu, Sep 25, 7:08 PM
Unknown Object (File)
Sat, Sep 20, 10:29 PM
Unknown Object (File)
Thu, Sep 18, 8:15 PM

Details

Summary

So-called pure sources provide entropy at regular intervals, so the
timestamp counter provides little entropy. Exclude it from health
testing for such sources.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Aug 28 2025, 9:48 PM
cem added inline comments.
sys/dev/random/random_harvestq.c
347

If callers are still consuming HARVESTSIZE+1 bytes, doesn't this just replace one deterministic value with another (0 from memset)?

sys/dev/random/random_harvestq.c
347

To be clear, the modified copy with dst[HARVESTSIZE] == 0 is only used for health testing, the original sample is passed unmodified to the entropy pools.

This does replace one deterministic value with another, but this way it's more likely that the health checks will catch problems with pure entropy sources. Without this change, if an entropy source is "stuck" and keeps providing the same value over and over, the inclusion of the timestamp might be enough to defeat the (quite weak) health tests. This is just a measure to try and make the health tests more effective.

sys/dev/random/random_harvestq.c
347

I wondered about that as well; your explanation makes sense. It's probably worth putting some of what you wrote here in a comment there.

This revision is now accepted and ready to land.Aug 29 2025, 1:53 PM
cem added inline comments.
sys/dev/random/random_harvestq.c
347

Makes sense.