Just to add more ubuntu/debian specific details because this includes a
kernel config options that was changed from vanilla kernel and that not
everyone may agree with and I had missed myself.

This seem to have started when crg_init was changed in the kernel to 1
to fix a CVE. This caused a change in behavior and after that fix when
calls to getrandom in the early boot were done it was now properly
blocking until it was securely initialized.

As described in this systemd discussion

https://github.com/systemd/systemd/issues/4167

This caused software that were calling getrandom without GRND_NONBLOCK
to now properly block. The problem is if any of those software did not
require this, e.g. they could use urandom instead or did not even need a
random number in the first place, and were called during the early boot
process they would cause the system to hang unnecessarily. This was what
happened with

"plymouth/fontconfig/libuuid (generating uuids requires randomness).
That specific UUID generation can be prevented, and util-linux 2.32
makes the getrandom call non-blocking."

which was fixed in util-linux 2.32 and was causing my long boot delay
before the login screen appeared. Now I was using 18.04 LTS which still
has util-linux 2.31 so the reason kernel 5.1.x was working when kernel
4.19 did not, was not because the source of the problem was really in
the kernel, it was because of this change in the ubuntu/debian kernel
that is not in the vanilla kernel

https://bugs.launchpad.net/ubuntu/+source/linux-azure/+bug/1823754

which sets CONFIG_RANDOM_TRUST_CPU=y instead of N on the vanilla kernel.
This kernel option was added in 4.19 by Theodore Ts'o and must have
landed somewhere in the ubuntu/debian kernel between 4.19 and 5.1

https://lwn.net/Articles/760121/

This is why a kernel who has CONFIG_RANDOM_TRUST_CPU=y and software that
wrongly call a blocking getrandom during boot time where crg_init is
still 1, i.e. random number generator is not fully initialized, does not
block if they have a CPU that support random number generation like many
modern CPU. Note that there is an associated boot option to change this
manually

random.trust_cpu=on/off

It seems like there might have been a time where the crg_init patch
landed and the CONFIG_RANDOM_TRUST_CPU=y was not there yet that may have
caused issues, but at least the state of the packages in 18.04 does not
have this problem for me. Nevertheless, while I will probably keep
CONFIG_RANDOM_TRUST_CPU=y I can see some hardware where this might not
be an appropriate default.

Therefore if someone wants to run with CONFIG_RANDOM_TRUST_CPU=N, and
util-linux < 2.32 or any other software that calls a blocking getrandom
at boot when it is not required, the only options left are software that
were suggested here like rng-tools and haveged to attempt to speed up
the kernel entropy generation.

In addition, to libuuid I also saw that the Bluetooth library may have
also at one point using wrongly a blocking getrandom call which seems to
be the problem of the original poster. However, I do not have this
library on this machine so I cannot verify but assume at some point that
library must have also been fixed down the line. Otherwise, any of the
fixes above would also work.

** Bug watch added: github.com/systemd/systemd/issues #4167
   https://github.com/systemd/systemd/issues/4167

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1685794

Title:
  Boot delayed for about 90 seconds until 'random: crng init done'

Status in linux package in Ubuntu:
  Confirmed
Status in broadcom-sta package in Debian:
  New

Bug description:

  Shortened dmesg output, notice the unnaturally long delay before crng
  init finishes:

  [    8.533630] Bluetooth: hci0: Intel Bluetooth firmware patch completed and 
activated
  [    8.542239] input: HDA Intel PCH Mic as 
/devices/pci0000:00/0000:00:1b.0/sound/card1/input18
  [    8.542313] input: HDA Intel PCH Line as 
/devices/pci0000:00/0000:00:1b.0/sound/card1/input19
  [    8.542382] input: HDA Intel PCH Dock Line Out as 
/devices/pci0000:00/0000:00:1b.0/sound/card1/input20
  [    8.542449] input: HDA Intel PCH Headphone as 
/devices/pci0000:00/0000:00:1b.0/sound/card1/input21
  [    8.544240] cdc_ether 2-6:2.0 usb0: register 'cdc_ether' at 
usb-0000:00:14.0-6, CDC Ethernet Device, 02:1e:10:1f:00:00
  [    8.544271] usbcore: registered new interface driver cdc_ether
  [    8.637660] ieee80211 phy0: Selected rate control algorithm 'iwl-mvm-rs'
  [    8.654022] input: HP WMI hotkeys as /devices/virtual/input/input22
  [    8.688226] cdc_ether 2-6:2.0 enp0s20u6c2: renamed from usb0
  [    8.713288] iwlwifi 0000:02:00.0 wlo1: renamed from wlan0
  [    9.804308] input: ST LIS3LV02DL Accelerometer as 
/devices/platform/lis3lv02d/input/input23
  [   98.327857] random: crng init done
  [   98.330072] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
  [   98.330073] Bluetooth: BNEP filters: protocol multicast
  [   98.330077] Bluetooth: BNEP socket layer initialized
  [   98.443281] kauditd_printk_skb: 90 callbacks suppressed
  [   98.492927] IPv6: ADDRCONF(NETDEV_UP): enp0s25: link is not ready
  [   98.681030] IPv6: ADDRCONF(NETDEV_UP): enp0s25: link is not ready
  [   98.685672] IPv6: ADDRCONF(NETDEV_UP): enp0s20u6c2: link is not ready
  [   98.685789] cdc_ether 2-6:2.0 enp0s20u6c2: kevent 12 may have been dropped
  [   98.688384] IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
  [   98.690915] iwlwifi 0000:02:00.0: L1 Enabled - LTR Enabled

  ProblemType: Bug
  DistroRelease: Ubuntu 17.04
  Package: linux-image-4.10.0-19-generic 4.10.0-19.21 [modified: 
boot/vmlinuz-4.10.0-19-generic]
  ProcVersionSignature: Ubuntu 4.10.0-19.21-generic 4.10.8
  Uname: Linux 4.10.0-19-generic x86_64
  ApportVersion: 2.20.4-0ubuntu4
  Architecture: amd64
  AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/by-path', 
'/dev/snd/hwC1D0', '/dev/snd/pcmC1D0c', '/dev/snd/pcmC1D0p', 
'/dev/snd/controlC1', '/dev/snd/hwC0D0', '/dev/snd/pcmC0D8p', 
'/dev/snd/pcmC0D7p', '/dev/snd/pcmC0D3p', '/dev/snd/controlC0', '/dev/snd/seq', 
'/dev/snd/timer'] failed with exit code 1:
  CurrentDesktop: Unity:Unity7
  Date: Mon Apr 24 14:58:33 2017
  EcryptfsInUse: Yes
  InstallationDate: Installed on 2017-04-18 (5 days ago)
  InstallationMedia: Ubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
  MachineType: Hewlett-Packard HP EliteBook 840 G1
  ProcFB: 0 inteldrmfb
  ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.10.0-19-generic.efi.signed 
root=UUID=9fb9fc1d-15a4-4e98-a2ae-bf572e0900d5 ro quiet splash vt.handoff=7
  PulseList: Error: command ['pacmd', 'list'] failed with exit code 1: No 
PulseAudio daemon running, or not running as session daemon.
  RelatedPackageVersions:
   linux-restricted-modules-4.10.0-19-generic N/A
   linux-backports-modules-4.10.0-19-generic  N/A
   linux-firmware                             1.164
  SourcePackage: linux
  UpgradeStatus: No upgrade log present (probably fresh install)
  dmi.bios.date: 05/23/2016
  dmi.bios.vendor: Hewlett-Packard
  dmi.bios.version: L71 Ver. 01.37
  dmi.board.name: 198F
  dmi.board.vendor: Hewlett-Packard
  dmi.board.version: KBC Version 15.59
  dmi.chassis.asset.tag: USH452L0B1
  dmi.chassis.type: 10
  dmi.chassis.vendor: Hewlett-Packard
  dmi.modalias: 
dmi:bvnHewlett-Packard:bvrL71Ver.01.37:bd05/23/2016:svnHewlett-Packard:pnHPEliteBook840G1:pvrA3009DD10203:rvnHewlett-Packard:rn198F:rvrKBCVersion15.59:cvnHewlett-Packard:ct10:cvr:
  dmi.product.name: HP EliteBook 840 G1
  dmi.product.version: A3009DD10203
  dmi.sys.vendor: Hewlett-Packard

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1685794/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to