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)
Tue, Mar 26, 8:55 AM
Unknown Object (File)
Feb 27 2024, 11:18 PM
Unknown Object (File)
Feb 21 2024, 12:58 PM
Unknown Object (File)
Dec 27 2023, 9:27 PM
Unknown Object (File)
Dec 27 2023, 9:27 PM
Unknown Object (File)
Dec 27 2023, 9:27 PM
Unknown Object (File)
Dec 27 2023, 9:27 PM
Unknown Object (File)
Dec 25 2023, 11:41 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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24608
Build 23391: arc lint + arc unit

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.