Page MenuHomeFreeBSD

random: Treat writes to /dev/random as separate from /entropy
ClosedPublic

Authored by markj on Jul 3 2025, 5:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jul 29, 7:22 AM
Unknown Object (File)
Tue, Jul 29, 2:57 AM
Unknown Object (File)
Mon, Jul 28, 4:14 PM
Unknown Object (File)
Mon, Jul 28, 3:51 AM
Unknown Object (File)
Fri, Jul 25, 1:52 PM
Unknown Object (File)
Fri, Jul 18, 9:12 PM
Unknown Object (File)
Jul 9 2025, 12:03 AM
Unknown Object (File)
Jul 8 2025, 11:46 PM
Subscribers

Details

Summary

RANDOM_CACHED is overloaded to refer both to entropy obtained from files
loaded by the boot loader, and entropy obtained via writes to
/dev/random. Introduce a new source, RANDOM_RANDOMDEV, to refer to the
latter. This is to enable treating RANDOM_CACHED as a special case in
the NIST health test implementation.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65256
Build 62139: arc lint + arc unit

Event Timeline

markj requested review of this revision.Jul 3 2025, 5:39 PM

Seems reasonable.

libexec/rc/rc.conf
697

I'm not totally sure I understand the mask change here, can you explain it?

sys/dev/random/random_harvestq.c
588–591

Does this have ABI implications for loadable modules?

libexec/rc/rc.conf
697

I'll update the description later too, but: this setting disables all environmental sources except SWI, INTERRUPT, NET_NG, NET_TUN, MOUSE, KEYBOARD, ATTACH, CACHED. That corresponds to a mask of 0x1ff (511). To avoid changing any behaviour with this patch, I changed this to 0x11ff so that RANDOMDEV is included too.

sys/dev/random/random_harvestq.c
588–591

Yes, I should bump __FreeBSD_version for this change. I believe the userspace ABI is unaffected so long as we don't change the ordering of "environmental" sources. That's because user_immutable_mask in random_check_uint_harvestmask() disallows enabling or disabling non-environmental sources, and I don't think there are any other userspace-facing interfaces which are affected.

This revision is now accepted and ready to land.Jul 7 2025, 4:50 PM