Bug 1976877

Summary: Please enable CONFIG_RANDOM_TRUST_CPU
Product: Red Hat Enterprise Linux 9 Reporter: Thomas Huth <thuth>
Component: kernelAssignee: Vladis Dronov <vdronov>
kernel sub component: Crypto QA Contact: Chunyu Hu <chuhu>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: medium    
Priority: medium CC: chuhu, crecklin, ddelcian, dhoward, herbert.xu, hkrzesin, lilu, liwan, mharri, miabbott, skozina, toneata, vdronov, walters
Version: 9.0Keywords: Triaged
Target Milestone: betaFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-5.14.0-0.rc4.35.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1830280 Environment:
Last Closed: 2021-12-02 23:18:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1988161    

Description Thomas Huth 2021-06-28 12:51:50 UTC
+++ This bug was initially created as a clone of Bug #1830280 +++

Split out from discussions in this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1778762#c23

The high level here is "synchronize with the current state of Fedora" for how entropy (/dev/random) works.  The two bigger recent changes in Linux are the builtin kernel jitter entropy (covered by the above bug) as well as CONFIG_RANDOM_TRUST_CPU (this bug).

Modern AWS instance types have hardware with RDRAND, but there's still no hypervisor entropy (unlike GCP which offers virtio-rng).

Booting a m5d.4xlarge instance for example, firstboot has:

[   19.887867] random: crng init done

That's quite slow; now obviously there are projects like rng-tools that try to address this but the problem is that particularly for CoreOS, we do a whole lot inside the initial ramdisk, so any userspace solution like rng-tools basically needs to be nearly the first process started - we want to support things like dm-crypt for the root filesystem.  

And not to mention a lot of parts of the kernel want entropy even before userspace is launched.

Whereas instead if I do:

# rpm-ostree kargs --append=random.trust_cpu=on
# systemctl reboot

I see the same thing we have with FCOS:

[    0.001000] random: crng done (trusting CPU's manufacturer)

i.e. basically immediately after kernel boot we aren't going to block on strong entropy.

Now, we *could* enable this kernel argument just for RHCOS but I'd want to  see an argument for why we don't have it enabled by default across the board (like Fedora has).

Comment 1 Thomas Huth 2021-06-28 12:54:44 UTC
Looks like the CONFIG_RANDOM_TRUST_CPU settings got lost in the RHEL9 kernel, but are set in the RHEL8 and Fedora kernels, thus we might want to enable this in RHEL9 kernels again:

$ grep -r CONFIG_RANDOM_TRUST_CPU redhat/
redhat/configs/common/generic/CONFIG_RANDOM_TRUST_CPU:# CONFIG_RANDOM_TRUST_CPU is not set
redhat/configs/fedora/generic/powerpc/CONFIG_RANDOM_TRUST_CPU:CONFIG_RANDOM_TRUST_CPU=y
redhat/configs/fedora/generic/s390x/CONFIG_RANDOM_TRUST_CPU:CONFIG_RANDOM_TRUST_CPU=y
redhat/configs/fedora/generic/x86/CONFIG_RANDOM_TRUST_CPU:CONFIG_RANDOM_TRUST_CPU=y

Comment 3 Vladis Dronov 2021-07-30 12:59:05 UTC
RHEL-8 configs are:

config-4.18.0-326.el8.ppc64le:CONFIG_RANDOM_TRUST_CPU=y
config-4.18.0-326.el8.s390x:CONFIG_RANDOM_TRUST_CPU=y
config-4.18.0-326.el8.x86_64:CONFIG_RANDOM_TRUST_CPU=y

make the same for the RHEL9.

Comment 4 Vladis Dronov 2021-07-30 13:21:52 UTC
(In reply to Thomas Huth from comment #1)
> Looks like the CONFIG_RANDOM_TRUST_CPU settings got lost in the RHEL9
> kernel,

Hello, Thomas,
If you have permissions needed, could you please ACK this merge request?

https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1287

Comment 5 Colin Walters 2021-07-30 14:08:30 UTC
Added this to the OpenShift tracker; I would probably vote for this one as a blocker for 9 final.

Comment 6 Vladis Dronov 2021-08-02 13:43:13 UTC
the ARK MR was merged: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1287

the change is under kernel-5.14.0-0.rc4.36 tag, so it will appear in C9S and RHEL9
kernels of this version and later ones.

Comment 11 Vladis Dronov 2021-08-11 13:42:10 UTC
the change has actually appeared in the 5.14.0-0.rc4.35.el9 version
of C9S and RHEL9 kernels, this bz is ready for tests:

c9s: kernel-core-5.14.0-0.rc4.35.el9.x86_64.rpm
$ grep TRUST_CPU lib/modules/5.14.0-0.rc4.35.el9.x86_64/config 
CONFIG_RANDOM_TRUST_CPU=y

rhel9: kernel-core-5.14.0-0.rc4.35.el9.x86_64.rpm
$ grep -e TRUST_CPU -e RHEL lib/modules/5.14.0-0.rc4.35.el9.x86_64/config
CONFIG_RANDOM_TRUST_CPU=y
CONFIG_RHEL_DIFFERENCES=y