pwarren/rtl-entropy

rngd(8) does not accept /var/run/rtl_entropy.fifo

Opened this issue · 10 comments

Following the instructions on site:

# rtl_entropy -b
# rngd -r /var/run/rtl_entropy.fifo -W 95%
# ps -ef | grep rngd
root      5597  3281  0 12:04 pts/3    00:00:00 grep rng

It seems that rngd(8) is not accepting named pipe as a valid hardware RNG. As such, as it stands, I cannot feed the data into the kernel entropy pool for processing to /dev/random.

I seem to have this same issue. echo $? returns '1'.

Can't replicate on my debian box.

Can you please get me the relevant bits of /var/log/daemon.log or where ever it is your system sends the rngd logs?

Heres the output I get from running the above, then doing a few runs of:
dd if=/dev/random of=/dev/null count=1024

Dec 19 21:46:22 hollis rtl-entropy[31451]: Options parsed, continuing.
Dec 19 21:46:22 hollis rtl-entropy[31451]: Waiting for a Reader...
Dec 19 21:46:30 hollis rtl-entropy[31451]: Found 1 device(s):
Dec 19 21:46:30 hollis rtl-entropy[31451]:   0:  GTek T803
Dec 19 21:46:30 hollis rtl-entropy[31451]: Using device 0: GTek T803
Dec 19 21:46:30 hollis rtl-entropy[31451]: Setting Frequency to 70000000
Dec 19 21:46:30 hollis rtl-entropy[31451]: Your device is capable of gains at...
Dec 19 21:46:30 hollis rtl-entropy[31451]:  : -9.90
Dec 19 21:46:30 hollis rtl-entropy[31451]:  : -4.00
Dec 19 21:46:30 hollis rtl-entropy[31451]:  : 7.10
Dec 19 21:46:30 hollis rtl-entropy[31451]:  : 17.90
Dec 19 21:46:30 hollis rtl-entropy[31451]:  : 19.20
Dec 19 21:46:30 hollis rtl-entropy[31451]: Setting gain to 19.20
Dec 19 21:46:30 hollis rtl-entropy[31451]: Doing FIPS init
Dec 19 21:46:30 hollis rtl-entropy[31451]: Reading samples in sync mode...
Dec 19 21:46:31 hollis rngd[31459]: rngd 2-unofficial-mt.14 starting up...
Dec 19 21:46:31 hollis rngd[31459]: entropy feed to the kernel ready
Dec 19 21:46:52 hollis rngd[31459]: block failed FIPS test: 0x04
Dec 19 21:47:03 hollis rngd[31459]: block failed FIPS test: 0x04
Dec 19 21:47:05 hollis rngd[31459]: block failed FIPS test: 0x08

After looking closer at it, it appears that I needed to blacklist the "dvb_usb_rtl28xxu" module for it to work. Also, this is the first I have come back to it since I reported this bug, so something may have also changed in Debian between then and now. But, it seems to be working now, so I'll close the issue.

So, interestingly enough, I have moved this to another machine. While it works great on my laptop, I cannot get rngd(8) to use the /var/run/rtl_entropy.fifo named pipe. Watching the data come into /var/run/rtl_entropy.fifo, it appears that it's bursting. IE- a burst of data comes in, then hangs, then a smaller burst, then hangs, then an even smaller burst, then hangs. Until eventually, it just hangs with no progress. I'm watching it with "xxd /var/run/rtl_entropy.fifo" These pauses might be what the issue was when I opened this bug, and what the problem is that I'm seeing now on my other computer.

Do you know what could be creating these bursts, and how to stop them?

$ ps -ef | grep rt[l]  
root     11434     1 17 11:01 ?        00:00:15 rtl_entropy -b
$ sudo rngd -r /var/run/rtl_entropy.fifo -f
rngd 2-unofficial-mt.14 starting up...
entropy feed to the kernel ready
entropy source exhausted!
stats: bits received from HRNG source: 1760000
stats: bits sent to kernel pool: 1740000
stats: entropy added to kernel pool: 1740000
stats: FIPS 140-2 successes: 87
stats: FIPS 140-2 failures: 0
stats: FIPS 140-2(2001-10-10) Monobit: 0
stats: FIPS 140-2(2001-10-10) Poker: 0
stats: FIPS 140-2(2001-10-10) Runs: 0
stats: FIPS 140-2(2001-10-10) Long run: 0
stats: FIPS 140-2(2001-10-10) Continuous run: 0
stats: HRNG source speed: (min=28.070; avg=502.418; max=19531250.000)Kibits/s
stats: FIPS tests speed: (min=79.805; avg=140.104; max=149.012)Mibits/s
stats: Lowest ready-buffers level: 0
stats: Entropy starvations: 87
stats: Time spent starving for entropy: (min=21; avg=39282.279; max=695754)us
Exiting...

Should I reopen the issue, or is the fix for this already known?

Okay, I've replicated this issue, first run of RNGD seems to work fine, then further runs get bursts from the named pipe exiting after a little bit.

Appear to be getting rather round numbers of entropy read by rngd, around 2220000 bits, so it's probably some sort of output oddness in rtl-entropy :)

it dosnt matter if its rngd or something else. if something is reading from the FIFO, then closes the handle and then open it again and try to read, it will break after a few kb sent trough the FIFO

W-M-D commented

What the issue actually is it opens however if the entropy pool is stressed or has not had enough time to generate data rngd will pull from the fifo until there is no data left and then kill itself because there is no data left.

W-M-D commented

I have tried with the -T flag with no effect.

I think I've been having the same issue on CentOS 7. The pool goes down to a really low number from a really high number.

W-M-D commented

So far what i have found is if you start rtl_entropy and then wait a few seconds ( i put 10 in my daemon ) before starting rngd the fifo has enough data in in that it will not dry up under normal operation. However , if the entropy pool is stressed rngd will run out of data and crash. The only workaround i see is incorporating the rngd code directly into rtl_entropy and adding the data directly to the random pool.