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)
Sat, Oct 11, 4:44 AM
Unknown Object (File)
Fri, Oct 10, 3:59 AM
Unknown Object (File)
Fri, Oct 10, 3:59 AM
Unknown Object (File)
Fri, Oct 10, 3:59 AM
Unknown Object (File)
Fri, Oct 10, 3:59 AM
Unknown Object (File)
Thu, Oct 9, 10:46 PM
Unknown Object (File)
Thu, Oct 2, 3:11 PM
Unknown Object (File)
Wed, Oct 1, 12:29 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 Not Applicable
Unit
Tests Not Applicable

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
590–593

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
590–593

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