From: Matt Mackall <mpm@selenic.com>
To: Folkert van Heusden <folkert@vanheusden.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: issue with /dev/random? gets depleted very quick
Date: Sun, 14 Jun 2009 10:51:09 -0500 [thread overview]
Message-ID: <1244994669.4496.229.camel@calx> (raw)
In-Reply-To: <20090614125138.GZ7272@vanheusden.com>
[cc:ed to lkml]
On Sun, 2009-06-14 at 14:51 +0200, Folkert van Heusden wrote:
> Hi,
>
> On an idle system (no gui, no daemons, nothing) system, /dev/random gets
> empty in a matter of 20 seconds with a 2.6.26 kernel.
>
> My test:
>
> add 1000 bits to the device:
>
> zolder:/tmp# cat test-RNDADDENTROPY.c
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <sys/ioctl.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <asm/types.h>
> #include <linux/random.h>
>
> int main(int argc, char *argv[])
> {
> struct rand_pool_info *output;
> int fd = open("/dev/random", O_WRONLY);
>
> output = (struct rand_pool_info *)malloc(10000);
> output -> entropy_count = 1000;
> output -> buf_size = 8000;
>
> printf("%d\n", ioctl(fd, RNDADDENTROPY, output));
>
> return 0;
> }
>
> and then check whayt is in it:
>
> zolder:/tmp# ./a.out ; while true ; do echo `date` `cat /proc/sys/kernel/random/entropy_avail` ; sleep 1 ; done
> 0
> Sun Jun 14 14:50:44 CEST 2009 1117
> Sun Jun 14 14:50:45 CEST 2009 989
> Sun Jun 14 14:50:46 CEST 2009 925
> Sun Jun 14 14:50:47 CEST 2009 797
> Sun Jun 14 14:50:48 CEST 2009 733
> Sun Jun 14 14:50:49 CEST 2009 605
> Sun Jun 14 14:50:50 CEST 2009 541
> Sun Jun 14 14:50:51 CEST 2009 413
> Sun Jun 14 14:50:52 CEST 2009 349
> Sun Jun 14 14:50:53 CEST 2009 221
> Sun Jun 14 14:50:54 CEST 2009 157
> Sun Jun 14 14:50:55 CEST 2009 157
>
> Is there something wrong with it?
Does it go below 128? If not, that's the behavior of something depleting
the pool down to the anti-starvation threshold via either /dev/urandom
or get_random_bytes.
On my system, I'm seeing that behavior as well. fuser reports a bunch of
processes hold /dev/urandom open, but stracing them doesn't reveal a
culprit. Which means there's now probably something in the kernel
calling get_random_bytes continuously.
Is this a problem? It really shouldn't be. Everyone should be
using /dev/urandom anyway. And the anti-starvation threshold guarantees
that if there's entropy being collected, readers of /dev/random can
always make forward progress.
--
http://selenic.com : development and support for Mercurial and Linux
next parent reply other threads:[~2009-06-14 15:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090614125138.GZ7272@vanheusden.com>
2009-06-14 15:51 ` Matt Mackall [this message]
2009-06-14 19:04 ` issue with /dev/random? gets depleted very quick Folkert van Heusden
2009-06-14 19:34 ` Matt Mackall
2009-06-14 19:58 ` Folkert van Heusden
2009-06-14 20:22 ` Matt Mackall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1244994669.4496.229.camel@calx \
--to=mpm@selenic.com \
--cc=folkert@vanheusden.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.