|
|
Log in / Subscribe / Register

Problems emerge for a unified /dev/*random

Problems emerge for a unified /dev/*random

Posted Apr 1, 2022 4:14 UTC (Fri) by wtarreau (subscriber, #51152)
Parent article: Problems emerge for a unified /dev/*random

I remember having discussed this problem with Jason a few years ago, saying that until we instrument boot loaders to feed entropy on embedded devices, it's a dead end. Indeed, the only source of entropy you can have on small devices are:
- pre-init device contents (uninitialized RAM usually contains noise, except in VMs);
output GPIOs may also read noise before they're configured as outputs. UARTs
often read a first crappy byte. Many chips also include a "reset cause" register
that indicates power-on, reset, exception, etc

- device reset timings (slow devices such as UARTs do not always take an integral
number of cycles to reset; RTC's second transition also solely depends on when
the device was booted, relative to the current second.

- the device's configuration: very often you'll find a MAC or some device-specific
WiFi calibration data stored in a special area on the flash, that may differ from
device to device. When running in a VM, some arguments may come from other
means.

- other external persistent info (e.g. any RTC time value that varies between boots)

But often all these data are lost after the boot loader finishes initialization and transfers execution to the kernel. We'll *need* to standardize a solution for this, that boot loaders will have to use for future kernels if we want to improve the situation for such embedded devices. Otherwise they're too deterministic. I do remember that the SSH key I used to have on my old NSLU2 existed on at least 89 other devices connected to the net... This definitely shows that without early entropy there's little hope to collect more later and whatever we'll try to do can result in frustration. And while VMs are terrible for this, at least they can benefit from entropy being spoon-fed at boot by the hypervisor.


to post comments

Problems emerge for a unified /dev/*random

Posted Apr 1, 2022 9:07 UTC (Fri) by wsy (subscriber, #121706) [Link] (2 responses)

I would never trust a boot loader unless it's open source. And I don't think SOC vendors will do that.

Problems emerge for a unified /dev/*random

Posted Apr 1, 2022 10:06 UTC (Fri) by nickleverton (subscriber, #81592) [Link] (1 responses)

U-Boot, which I would guess is probably used by most embedded devices that boot into Linux, is GPL2.0+. It's ideally placed to extract the early boot hardware-based randomness that Willy Tarreau mentions, running after any SoC ROM loader but before the Linux kernel. I am sure Grub could do similar things for bigger SoCs that boot from disk.

Problems emerge for a unified /dev/*random

Posted Apr 1, 2022 12:07 UTC (Fri) by wtarreau (subscriber, #51152) [Link]

Yes U-Boot definitely is the best place here, since it often embeds the SPL code that's used to train the DDR memory. Typically the training is a good way to produce entropy since it tries timings for reliable transfers.

For the PC world, grub might be too late due to the BIOS often doing most of the cleanup. However on PCs there's often a video card whose memory is not reset and which contains garbage. I think it already happened to all of us to power-cycle a PC, then discover a fantom image of previous session for a fraction of a second when typing "startx" because that memory wasn't completely lost yet. And most PCs have hardware RNGs and jitter entropy anyway ;-)


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds