Bug 2128954 - rngd from rng-tools-6.15-4.fc37 started, stopped, started, and failed when booting
Summary: rngd from rng-tools-6.15-4.fc37 started, stopped, started, and failed when bo...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: rng-tools
Version: 37
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Vladislav Dronov (Fedora)
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-09-22 05:36 UTC by Matt Fagnani
Modified: 2022-12-30 16:07 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2022-12-30 16:07:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Matt Fagnani 2022-09-22 05:36:13 UTC
Description of problem:

I upgraded a Fedora 37 KDE Plasma installation with updates-testing enabled 
sudo dnf offline-upgrade download 
sudo dnf offline-upgrade reboot

The updates included rng-tools-6.15-4.fc37. I had rngd.service enabled. On the following boot, I noticed a rngd problem at first by running systemctl list-units --state=failed
rngd started, stopped, started again then failed with an error like "rngd[872]: Can't open any entropy source" in the journal.

Sep 21 23:06:28 systemd[1]: Started rngd.service - Hardware RNG Entropy Gatherer Daemon.
Sep 21 23:06:28 rngd[248]: Initializing available sources
Sep 21 23:06:28 rngd[248]: [hwrng ]: Initialization Failed
Sep 21 23:06:28 rngd[248]: [rdrand]: Initialization Failed
Sep 21 23:06:28 rngd[248]: [jitter]: Initializing AES buffer
Sep 21 23:06:34 rngd[248]: [jitter]: Enabling JITTER rng support
Sep 21 23:06:34 rngd[248]: [jitter]: Initialized
Sep 21 23:06:34 rngd[248]: [pkcs11]: Unable to load pkcs11 engine: (null)
Sep 21 23:06:34 rngd[248]: [pkcs11]: Initialization Failed
Sep 21 23:06:34 rngd[248]: [rtlsdr]: Initialization Failed
Sep 21 23:06:35 systemd[1]: Stopping rngd.service - Hardware RNG Entropy Gatherer Daemon...
Sep 21 23:06:35 rngd[248]: [jitter]: Shutting down
Sep 21 23:06:35 systemd[1]: rngd.service: Deactivated successfully.
Sep 21 23:06:35 systemd[1]: Stopped rngd.service - Hardware RNG Entropy Gatherer Daemon.
Sep 21 23:06:35 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Sep 21 23:06:35 systemd[1]: rngd.service: Consumed 19.962s CPU time.
Sep 21 23:06:42 systemd[1]: Started rngd.service - Hardware RNG Entropy Gatherer Daemon.
Sep 21 23:06:42 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Sep 21 23:06:42 rngd[872]: Disabling 7: PKCS11 Entropy generator (pkcs11)
Sep 21 23:06:42 rngd[872]: Disabling 5: NIST Network Entropy Beacon (nist)
Sep 21 23:06:42 rngd[872]: Initializing available sources
Sep 21 23:06:42 rngd[872]: [hwrng ]: Initialization Failed
Sep 21 23:06:42 rngd[872]: [rdrand]: Initialization Failed
Sep 21 23:06:42 rngd[872]: [jitter]: JITTER timeout set to 5 sec
Sep 21 23:06:42 rngd[872]: [jitter]: Initializing AES buffer
Sep 21 23:06:47 rngd[872]: [jitter]: Unable to obtain AES key, disabling JITTER source
Sep 21 23:06:47 rngd[872]: [jitter]: Initialization Failed
Sep 21 23:06:47 rngd[872]: [rtlsdr]: Initialization Failed
Sep 21 23:06:47 rngd[872]: Can't open any entropy source
Sep 21 23:06:47 rngd[872]: Maybe RNG device modules are not loaded
Sep 21 23:06:47 systemd[1]: rngd.service: Main process exited, code=exited, status=1/FAILURE
Sep 21 23:06:47 systemd[1]: rngd.service: Failed with result 'exit-code'.
Sep 21 23:06:47 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Sep 21 23:06:47 systemd[1]: rngd.service: Consumed 11.403s CPU time.

Version-Release number of selected component (if applicable):
rng-tools-6.15-4.fc37

How reproducible:
rngd failed on 3/3 boots with rng-tools-6.15-4.fc37

Steps to Reproduce:
1. Boot a Fedora 37 KDE Plasma installation
2. Log in to Plasma on Wayland
3. Start Konsole
4. Install rng-tools if it isn't already with sudo dnf install rng-tools
I had rng-tools installed already.
5. Enable rngd.service if it isn't already with sudo systemctl enable rngd
I had rngd.service enabled already.
6. sudo dnf offline-upgrade download 
7. sudo dnf offline-upgrade reboot
8. On the boot after the update, Log in to Plasma
9. Start konsole
10. systemctl list-units --state=failed
11. systemctl status rngd


Actual results:
rngd from rng-tools-6.15-4.fc37 started, stopped, started, and failed when booting

Expected results:
rngd wouldn't fail in this way.

Additional info:

rngd.service didn't fail in this way with rng-tools-6.15-3.fc37. I downgraded to rng-tools-6.15-3.fc37 with sudo dnf downgrade rng-tools
I rebooted. On the boot after downgrading to rng-tools-6.15-3.fc37, rngd started, stopped, started and remained running as shown below.

Sep 22 01:09:47 systemd[1]: Started rngd.service - Hardware RNG Entropy Gatherer Daemon.
Sep 22 01:09:47 rngd[247]: Initializing available sources
Sep 22 01:09:47 rngd[247]: [hwrng ]: Initialization Failed
Sep 22 01:09:47 rngd[247]: [rdrand]: Initialization Failed
Sep 22 01:09:47 rngd[247]: [jitter]: Initializing AES buffer
Sep 22 01:09:53 rngd[247]: [jitter]: Enabling JITTER rng support
Sep 22 01:09:53 rngd[247]: [jitter]: Initialized
Sep 22 01:09:53 rngd[247]: [pkcs11]: Unable to load pkcs11 engine: (null)
Sep 22 01:09:53 rngd[247]: [pkcs11]: Initialization Failed
Sep 22 01:09:53 rngd[247]: [rtlsdr]: Initialization Failed
Sep 22 01:09:54 systemd[1]: Stopping rngd.service - Hardware RNG Entropy Gatherer Daemon...
Sep 22 01:09:54 rngd[247]: [jitter]: Shutting down
Sep 22 01:09:54 systemd[1]: rngd.service: Deactivated successfully.
Sep 22 01:09:54 systemd[1]: Stopped rngd.service - Hardware RNG Entropy Gatherer Daemon.
Sep 22 01:09:54 audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Sep 22 01:09:54 systemd[1]: rngd.service: Consumed 19.702s CPU time.
Sep 22 01:10:01 systemd[1]: Started rngd.service - Hardware RNG Entropy Gatherer Daemon.
Sep 22 01:10:01 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Sep 22 01:10:01 rngd[871]: Disabling 7: PKCS11 Entropy generator (pkcs11)
Sep 22 01:10:01 rngd[871]: Disabling 5: NIST Network Entropy Beacon (nist)
Sep 22 01:10:01 rngd[871]: Initializing available sources
Sep 22 01:10:01 rngd[871]: [hwrng ]: Initialization Failed
Sep 22 01:10:01 rngd[871]: [rdrand]: Initialization Failed
Sep 22 01:10:01 rngd[871]: [jitter]: Initializing AES buffer
Sep 22 01:10:08 rngd[871]: [jitter]: Enabling JITTER rng support
Sep 22 01:10:08 rngd[871]: [jitter]: Initialized
Sep 22 01:10:08 rngd[871]: [rtlsdr]: Initialization Failed
Sep 22 01:10:08 rngd[871]: Process privileges have been dropped to 2:2

Comment 1 Vladislav Dronov 2022-12-27 14:50:27 UTC
Hi, Matt,
Thank you for a report. Let me provide a research here. These are upstream commits for rng-tools versions:

rng-tools-6.15-3 - 172bf0e3
rng-tools-6.15-4 - 6dcc9ec2

Previously jitter source was waiting infinitely if it could not gather enough entropy from system events to start.
Usually this is not a problem, since systems have another sources of entropy. In your case:

Sep 22 01:10:01 rngd[871]: Initializing available sources
Sep 22 01:10:01 rngd[871]: [hwrng ]: Initialization Failed
Sep 22 01:10:01 rngd[871]: [rdrand]: Initialization Failed
Sep 22 01:10:01 rngd[871]: [jitter]: Initializing AES buffer
Sep 22 01:10:08 rngd[871]: [jitter]: Enabling JITTER rng support
Sep 22 01:10:08 rngd[871]: [jitter]: Initialized
Sep 22 01:10:08 rngd[871]: [rtlsdr]: Initialization Failed

you have only jitter as a source of entropy. These commits added a timeout for jitter source so it does not starts
up infinitely:

c29424f10a0d Adjust jitterentropy library to timeout/fail on long delay
6e14b8bd491b rngd_jitter: make timeout configurable

Your log says:

Sep 21 23:06:42 rngd[872]: Initializing available sources
Sep 21 23:06:42 rngd[872]: [hwrng ]: Initialization Failed
Sep 21 23:06:42 rngd[872]: [rdrand]: Initialization Failed
Sep 21 23:06:42 rngd[872]: [jitter]: JITTER timeout set to 5 sec           <<< THIS
Sep 21 23:06:42 rngd[872]: [jitter]: Initializing AES buffer
Sep 21 23:06:47 rngd[872]: [jitter]: Unable to obtain AES key, disabling JITTER source
Sep 21 23:06:47 rngd[872]: [jitter]: Initialization Failed
Sep 21 23:06:47 rngd[872]: [rtlsdr]: Initialization Failed
Sep 21 23:06:47 rngd[872]: Can't open any entropy source

that jitter source couldn't initialize in 5 seconds (the default timeout), there was not enough random event happening
in your system. So rngd has quit, as there were no sources. Please use the following switch (in /etc/sysconfig/rngd) to
increase jitter init timeout on your system (a value is in seconds):

-O jitter:timeout:$RNGD_JITTER_TIMEOUT

PLEASE NOTE, as gathering jitter is an inherently random process there is no certain timeout to 100% guarantee that jitter
source gather enough randomness during this timeout. A suggestion is to set a high timeout (like 240) to simulate infinite
timeout of a previous rngd version.

HTH.

Comment 2 Matt Fagnani 2022-12-27 19:37:12 UTC
I changed RNGD_ARGS="-x pkcs11 -x nist -D daemon:daemon -O jitter:timeout:240" in /etc/sysconfig/rngd. I restarted rngd from rng-tools-6.15-4.fc37 or rebooted a few times. rngd started normally after 6-8 seconds based on the times in the journal such as the following.

Dec 27 14:09:02 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 27 14:09:02 rngd[889]: Disabling 7: PKCS11 Entropy generator (pkcs11)
Dec 27 14:09:02 rngd[889]: Disabling 5: NIST Network Entropy Beacon (nist)
Dec 27 14:09:02 rngd[889]: Initializing available sources
Dec 27 14:09:02 rngd[889]: [hwrng ]: Initialization Failed
Dec 27 14:09:02 rngd[889]: [rdrand]: Initialization Failed
Dec 27 14:09:02 rngd[889]: [jitter]: JITTER timeout set to 240 sec
Dec 27 14:09:02 rngd[889]: [jitter]: Initializing AES buffer
Dec 27 14:09:02 systemd[1]: Started rngd.service - Hardware RNG Entropy Gatherer Daemon.
Dec 27 14:09:09 rngd[889]: [jitter]: Enabling JITTER rng support
Dec 27 14:09:09 rngd[889]: [jitter]: Initialized
Dec 27 14:09:09 rngd[889]: [rtlsdr]: Initialization Failed
Dec 27 14:09:09 rngd[889]: Process privileges have been dropped to 2:2

Thanks. The CPU is an AMD A10-9620P which has the RDRAND instruction/RNG. I read that the kernel was changed not to show the availability of RDRAND on some older AMD CPUs https://lore.kernel.org/lkml/776cb5c2d33e7fd0d2893904724c0e52b394f24a.1565817448.git.thomas.lendacky@amd.com/ So that might be related to why jitter was the only source of entropy on my system.

Comment 3 Vladislav Dronov 2022-12-27 22:27:00 UTC
thanks for the link, Matt, interesting read. so you may try "rdrand=force" kernel parameter to disable this rdrand-hiding behavior.

with that, i believe, this bz can be closed, please, tell if not.

Comment 4 Matt Fagnani 2022-12-28 02:58:16 UTC
The rngd startup default timeout length might still need to be increased upstream or downstream so that others with similar systems don't have this problem. Unless one looks for this problem with systemctl or journalctl, they might not realize that rngd is failing to start each time since there's no normal notification of it happening. I booted with rdrand=force on the kernel command line. RDRAND started correctly in the rngd journal messages, and rngd still took 7-9 seconds to start with RDRAND enabled.

Dec 27 21:41:57 systemd[1]: Started rngd.service - Hardware RNG Entropy Gatherer Daemon.
Dec 27 21:41:57 audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=rngd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Dec 27 21:41:57 rngd[878]: Disabling 7: PKCS11 Entropy generator (pkcs11)
Dec 27 21:41:57 rngd[878]: Disabling 5: NIST Network Entropy Beacon (nist)
Dec 27 21:41:57 rngd[878]: Initializing available sources
Dec 27 21:41:57 rngd[878]: [hwrng ]: Initialization Failed
Dec 27 21:41:57 rngd[878]: [rdrand]: Enabling RDRAND rng support
Dec 27 21:41:57 rngd[878]: [rdrand]: Initialized
Dec 27 21:41:57 rngd[878]: [jitter]: JITTER timeout set to 240 sec
Dec 27 21:41:57 rngd[878]: [jitter]: Initializing AES buffer
Dec 27 21:42:04 rngd[878]: [jitter]: Enabling JITTER rng support
Dec 27 21:42:04 rngd[878]: [jitter]: Initialized
Dec 27 21:42:04 rngd[878]: [rtlsdr]: Initialization Failed
Dec 27 21:42:04 rngd[878]: Process privileges have been dropped to 2:2

Thanks.

Comment 5 Vladislav Dronov 2022-12-30 16:07:49 UTC
(In reply to Matt Fagnani from comment #4)
> I booted with rdrand=force on the
> kernel command line. RDRAND started correctly in the rngd journal messages,

great to hear this.

> and rngd still took 7-9 seconds to start with RDRAND enabled.

jitter source does not use rdrand, it is a different independent source.
so now as you have rdrand you may want to disable jitter (and rtlsdr)
sources so they do not slow down rngd's startup. with: -x jitter -x rtlsdr

i believe i can close this, please reopen if not.


Note You need to log in before you can comment on or make changes to this bug.