21

For a class on cryptography, I am trying to drain the entropy pool in Linux (e.g. make /proc/sys/kernel/random/entropy_avail go to 0 and block a command reading from /dev/random) but I can't make it happen. I'm supposed to get reads from /dev/random to block. If I execute these two commands:

watch -n 0.5 cat /proc/sys/kernel/random/entropy_avail

to watch entropy and then:

od -d /dev/random

to dump the random pool, the value from the watch command hovers between 3700 and 3900, and gains and loses only a little while I run this command. I let both commands run for about three minutes with no discernible substantial change in the size of entropy_avail. I didn't do much on the computer during that time. From googling around I find that perhaps a hardware random number generator could be so good that the entropy won't drop but if I do:

cat /sys/devices/virtual/misc/hw_random/rng_available

I see nothing, I just get a blank line. So I have a few questions:

  1. What's replenishing my entropy so well, and how can I find the specific source of randomness?
  2. Is there any way to temporarily disable sources of randomness so I can force this blocking to happen?
2

3 Answers 3

33

There is a surprising amount of development going on around the Linux random device. The slow, blocking /dev/random is gone and replaced by a fast /dev/random that never runs out of data.

You'll have to travel back in time, like prior to linux 4.8 (which introduced a much faster crng algorithm) or possibly linux 5.6 (which introduced jitter entropy generation).

There is no way to get the original behavior back in current kernels.


If you are seeing this issue in older versions of Linux, hwrng aside, you might be using haveged or rng-tools rngd, or similar userspace entropy providers.

Some distros install these by default to avoid hangs while waiting for a few random bits, in that case you can uninstall or disable them or try it from within an initrd / busybox shell where no other processes are running.

If the issue still persists, you might just have a very noisy piece of hardware from which kernel keeps collecting entropy naturally.

21

What's replenishing my entropy so well, and how can I find the specific source of randomness?

As of kernel 5.6, /dev/random obtains randomness from the kernel's CRNG, which is initialized during boot and does not block.

See "Removing the Linux /dev/random blocking pool".

Is there any way to temporarily disable sources of randomness so I can force this blocking to happen?

I think you would have to use a pre-5.6 kernel.

5

This can depend on your hardware if it's using the CPU features then it might be endless. Other hardware is not.

However, you could try the kernel option random.trust_cpu=off when booting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.