Page MenuHomeFreeBSD

random(4): Fix RANDOM_LOADABLE build
ClosedPublic

Authored by cem on May 29 2019, 9:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 5 2024, 10:22 AM
Unknown Object (File)
Oct 19 2024, 10:20 AM
Unknown Object (File)
Oct 18 2024, 2:05 AM
Unknown Object (File)
Oct 3 2024, 10:44 PM
Unknown Object (File)
Oct 3 2024, 10:11 PM
Unknown Object (File)
Oct 1 2024, 1:05 PM
Unknown Object (File)
Oct 1 2024, 6:07 AM
Unknown Object (File)
Sep 27 2024, 9:39 AM
Subscribers

Details

Summary

I introduced an obvious compiler error in r346282, so this change fixes
that.

Unfortunately, RANDOM_LOADABLE isn't covered by our existing tinderbox, and
it seems like there were existing latent linking problems. I believe these
were introduced on accident in r338324 during reduction of the boolean
expression(s) adjacent to randomdev.c and hash.c. It seems the
RANDOM_LOADABLE build breakage has gone unnoticed for nine months.

This change correctly annotates randomdev.c and hash.c with !random_loadable
to match the pre-r338324 logic; and additionally updates the HWRNG drivers
in MD 'files.*', which depend on random_device symbols, with
!random_loadable (it is invalid for the kernel to depend on symbols from a
module).

(The expression for both randomdev.c and hash.c was the same, prior to
r338324: "optional random random_yarrow | random !random_yarrow
!random_loadable". I.e., "random && (yarrow || !loadable)." When Yarrow
was removed ("yarrow := False"), the expression was incorrectly reduced to
"optional random" when it should have retained "random && !loadable".)

Additionally, I discovered that virtio_random was missing a MODULE_DEPEND on
random_device, which breaks kld load/link of the driver on RANDOM_LOADABLE
kernels. Address that issue as well.

PR: 238223
Reported by: Eir Nym <eirnym AT gmail.com>

Test Plan
Loading kernel...
/boot/test.GENERIC-LOADABLERANDOM/kernel text=0x16527a4 data=0x1f0678+0x61a058 syms=[0x8+0x1a3928+0x8+0x1657f7]
Loading configured modules...
/boot/test.GENERIC-LOADABLERANDOM/random_fortuna.ko size 0x9c08 at 0x2567000
/boot/entropy size=0x1000
...
random: unblocking device.
...
random: entropy device external interface
...
Setting up harvesting: [UMA],[FS_ATIME],SWI,INTERRUPT,NET_NG,[NET_ETHER],NET_TUN,MOUSE,KEYBOARD,ATTACH,CACHED
Feeding entropy: .
...
Starting devd.
Autoloading module: virtio_random.ko
vtrnd0: <VirtIO Entropy Adapter> on virtio_pci0
random: registering fast source VirtIO Entropy Adapter
...
testvm# kldstat
Id Refs Address                Size Name
 1   11 0xffffffff80200000  2366800 kernel
 2    2 0xffffffff82567000     9c08 random_fortuna.ko
 3    1 0xffffffff82611000      830 virtio_random.ko
 4    1 0xffffffff82612000      b68 mac_ntpd.ko
...
testvm# kldload rdrand_rng
random: registering fast source Intel Secure Key RNG
random: fast provider: "Intel Secure Key RNG"

testvm# sysctl kern.random
kern.random.harvest.mask_symbolic: PURE_VIRTIO,PURE_RDRAND,[UMA],[FS_ATIME],SWI,INTERRUPT,NET_NG,[NET_ETHER],NET_TUN,MOUSE,KEYBOARD,ATTACH,CACHED
kern.random.random_sources: 'Intel Secure Key RNG','VirtIO Entropy Adapter'
...

testvm# dd if=/dev/random of=/dev/null bs=1m count=10
10+0 records in
10+0 records out
10485760 bytes transferred in 0.024659 secs (425238167 bytes/sec)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.May 30 2019, 2:19 AM
  • Fix linking errors introduced inadvertently in r338324
  • Correct MD HWRNG drivers in files.* to specify !random_loadable

RANDOM_LOADABLE now builds, and so long as 'random_fortuna_load="YES"' is added
to loader.conf, boots and functions.

This revision now requires review to proceed.May 30 2019, 7:55 PM
cem retitled this revision from random(4): Fix RANDOM_LOADABLE option build to random(4): Fix RANDOM_LOADABLE build.May 30 2019, 7:58 PM
cem edited the summary of this revision. (Show Details)
cem edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.May 31 2019, 7:44 AM
This revision was automatically updated to reflect the committed changes.