* [uml-devel] /dev/random oddity
@ 2004-03-13 1:49 Thomas Schwinge
2004-03-13 13:17 ` Sven 'Darkman' Michels
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Schwinge @ 2004-03-13 1:49 UTC (permalink / raw)
To: user-mode-linux-devel
[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]
Hello again!
Could you please try to compile and execute the attached file?
It's part of skalibs <URL:http://www.skarnet.org/software/skalibs/> and
is used to check if /dev/random is working correctly.
On a native Linux system this is no problem:
#v+
thomas@speedy:~/tmp > gcc -o trydevr trydevr.c
thomas@speedy:~/tmp > strace ./trydevr
execve("./trydevr", ["./trydevr"], [/* 59 vars */]) = 0
[...]
open("/dev/random", O_RDONLY) = 3
read(3, "\26\3239Q^\327\246\373\f\250c\5\333W\311\266\237m\\\231"..., 64) = 64
close(3) = 0
open("/dev/random", O_RDONLY) = 3
read(3, "\276Hj=W\311\237:\200F\1\262Z\266c\313\346k\202_\3348\317"..., 64) = 64
close(3) = 0
exit_group(0) = ?
#v-
Whereas on UML it is:
#v+
thomas@uml:~/tmp > gcc -o trydevr trydevr.c
thomas@uml:~/tmp > strace ./trydevr
execve("./trydevr", ["./trydevr"], [/* 55 vars */]) = 0
[...]
open("/dev/random", O_RDONLY) = 3
read(3, "\274\202\216\375\350\"\207W\221Y4Q\345QW\250\345\361 \305"..., 64) = 21
read(3, [hangs here]
#v-
The program is only able to read 21 bytes from /dev/random; sometimes
it's not even able to read anything at all.
#v+
thomas@uml:~ > cat /dev/random | sed 's|.|*|g'
#v-
does not return anything.
#v+
thomas@speedy:~ > cat /dev/random | sed 's|.|*|g'
#v-
returns a lot of '*' and then stops to refill until the kernel has
refilled it's entropy pool (see drivers/char/random.c) - refilling
happens by gathering random events e.g. interrupts - moving the mouse
or keeping a key pressed as examples.
/dev/random only returns random numbers from the entropy pool whereas
/dev/urandom also returns 'weak' (calculated) random numbers.
On UML the entropy pool seems never to be refilled - not matter how long
I keep a key pressed; I don't have a mouse there - so AFAICT /dev/random
stops working at the time the pool gets empty.
Might this be the problem?
UML is linux-2.6.4 with uml-patch-2.6.4-1 and
<URL:http://www.metaparadigm.com/~mclark/uml/uml-2.6.3-skas-1.patch>.
Regards,
Thomas
[-- Attachment #2: trydevr.c --]
[-- Type: text/plain, Size: 1151 bytes --]
/* Public domain. */
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
static int fd_read (int fd, char *buf, unsigned int len)
{
register int r ;
do r = read(fd, buf, len) ;
while ((r == -1) && (errno == EINTR)) ;
return r ;
}
static unsigned int allread (int fd, register char *buf, register unsigned int len)
{
register unsigned int written = 0 ;
while (len)
{
register int w = fd_read(fd, buf, len) ;
if (!w) errno = EPIPE ;
if (w <= 0) break ;
written += w ;
buf += w ;
len -= w ;
}
return written ;
}
static int byte_diff (char *s, unsigned int n, char *t)
{
for (;;)
{
if (!n) return 0 ;
if (*s != *t) break ;
++s ; ++t ; --n ;
}
return ((int)(unsigned int)(unsigned char) *s)
- ((int)(unsigned int)(unsigned char) *t);
}
int main ()
{
char a[64] ;
char b[64] ;
int fd ;
fd = open("/dev/random", O_RDONLY) ;
if ((fd == -1) || (allread(fd, a, 64) < 64) ) return 111 ;
close(fd) ;
fd = open("/dev/random", O_RDONLY) ;
if ((fd == -1) || (allread(fd, b, 64) < 64) ) return 111 ;
close(fd) ;
return !byte_diff(a, 64, b) ;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
2004-03-13 1:49 [uml-devel] /dev/random oddity Thomas Schwinge
@ 2004-03-13 13:17 ` Sven 'Darkman' Michels
2004-03-13 15:12 ` Stephen D. Williams
2004-03-15 19:41 ` Jeff Dike
0 siblings, 2 replies; 8+ messages in thread
From: Sven 'Darkman' Michels @ 2004-03-13 13:17 UTC (permalink / raw)
To: user-mode-linux-devel
Thomas Schwinge wrote:
> On UML the entropy pool seems never to be refilled - not matter how long
> I keep a key pressed; I don't have a mouse there - so AFAICT /dev/random
> stops working at the time the pool gets empty.
never is wrong, you can 'fill' the pool by doing some work like find /
ps aux etc, but this is really slow in filling up the pool. Maybe
other things should be used to fill the pool, too. Jeff? Blaisor?
anyone? ;)
Regards,
Sven
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
2004-03-13 13:17 ` Sven 'Darkman' Michels
@ 2004-03-13 15:12 ` Stephen D. Williams
2004-03-14 22:40 ` Matt Zimmerman
2004-03-15 19:41 ` Jeff Dike
1 sibling, 1 reply; 8+ messages in thread
From: Stephen D. Williams @ 2004-03-13 15:12 UTC (permalink / raw)
To: Sven 'Darkman' Michels; +Cc: user-mode-linux-devel
This is a bit beyond our scope here, but one ideal source for randomness
is LavaRnd: http://www.lavarnd.org/
If you set that up and run trickle, it will stock /dev/random with some
true randomness. I'm not sure why they apparently didn't increase
"/dev/random's vague notion of the amount of entropy available" since
lavarnd can generate so much random data quickly. That should be fixed
as far as I can see.
Getting this working with UML, and in fact feeding multiple UMLs with
high quality random data, would be very useful.
Related to this would be multiplexing PKI smart cards and HSMs accross
multiple UMLs. I'm going to need this soon.
sdw
Sven 'Darkman' Michels wrote:
> Thomas Schwinge wrote:
>
>> On UML the entropy pool seems never to be refilled - not matter how long
>> I keep a key pressed; I don't have a mouse there - so AFAICT /dev/random
>> stops working at the time the pool gets empty.
>
>
> never is wrong, you can 'fill' the pool by doing some work like find /
> ps aux etc, but this is really slow in filling up the pool. Maybe
> other things should be used to fill the pool, too. Jeff? Blaisor?
> anyone? ;)
>
> Regards,
> Sven
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> User-mode-linux-devel mailing list
> User-mode-linux-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
--
swilliams@hpti.com http://www.hpti.com Personal: sdw@lig.net http://sdw.st
Stephen D. Williams 703-724-0118W 703-995-0407Fax 20147-4622 AIM: sdw
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
2004-03-13 15:12 ` Stephen D. Williams
@ 2004-03-14 22:40 ` Matt Zimmerman
2004-03-15 19:37 ` Jeff Dike
0 siblings, 1 reply; 8+ messages in thread
From: Matt Zimmerman @ 2004-03-14 22:40 UTC (permalink / raw)
To: user-mode-linux-devel
On Sat, Mar 13, 2004 at 10:12:27AM -0500, Stephen D. Williams wrote:
> This is a bit beyond our scope here, but one ideal source for randomness
> is LavaRnd: http://www.lavarnd.org/
LavaRnd is software, and like any other software cannot be a source of
entropy. From reading the web page, it seems to rely on hardware to import
entropy from an external source, which is less than ideal for use with UML.
If the host has a steady supply of randomness from any source, then UML
should be able to simply read from /dev/random on the host.
--
- mdz
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
2004-03-14 22:40 ` Matt Zimmerman
@ 2004-03-15 19:37 ` Jeff Dike
[not found] ` <Pine.LNX.4.58.0403151422320.13832@gradall.private.brainfood.com>
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Dike @ 2004-03-15 19:37 UTC (permalink / raw)
To: user-mode-linux-devel
On Sun, Mar 14, 2004 at 02:40:08PM -0800, Matt Zimmerman wrote:
> If the host has a steady supply of randomness from any source, then UML
> should be able to simply read from /dev/random on the host.
That could be done. it would require replacing the generic /dev/random with
a UML one, and I don't know whether the kernel build makes that easy.
Another alternative is to add an mconsole interface to dump randomness into
a UML when it starts running out.
The current UML practice of feeding /dev/random from the drivers is a bit
suspect. The randomness obtained there is related to the host randomness,
but the host random pool isn't depleted accordingly.
I think the right solution is to feed UML /dev/random from the host /dev/random
somehow.
Jeff
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
2004-03-13 13:17 ` Sven 'Darkman' Michels
2004-03-13 15:12 ` Stephen D. Williams
@ 2004-03-15 19:41 ` Jeff Dike
1 sibling, 0 replies; 8+ messages in thread
From: Jeff Dike @ 2004-03-15 19:41 UTC (permalink / raw)
To: Sven 'Darkman' Michels; +Cc: user-mode-linux-devel
On Sat, Mar 13, 2004 at 02:17:50PM +0100, Sven 'Darkman' Michels wrote:
> never is wrong, you can 'fill' the pool by doing some work like find /
> ps aux etc, but this is really slow in filling up the pool. Maybe
> other things should be used to fill the pool, too. Jeff? Blaisor?
> anyone? ;)
That doesn't fill the random pool directly. What it does do is cause disk
IO, and the ubd driver will refill the random pool. It's a bit heavy-weight
for generating randomness, and I don't really like it anyway. See my other
reply in this thread.
Jeff
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
[not found] ` <Pine.LNX.4.58.0403151422320.13832@gradall.private.brainfood.com>
@ 2004-03-15 21:16 ` Jeff Dike
2004-03-18 19:06 ` BlaisorBlade
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Dike @ 2004-03-15 21:16 UTC (permalink / raw)
To: Adam Heath; +Cc: user-mode-linux-devel
On Mon, Mar 15, 2004 at 02:23:14PM -0600, Adam Heath wrote:
> It doesn't.
Figures.
> It'd be nice if there was a generic device mapper between UML and the host, so
> any device could be proxied, block or char.
Yeah, that would be a good plan. Too bad about kbuild though.
Jeff
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [uml-devel] /dev/random oddity
2004-03-15 21:16 ` Jeff Dike
@ 2004-03-18 19:06 ` BlaisorBlade
0 siblings, 0 replies; 8+ messages in thread
From: BlaisorBlade @ 2004-03-18 19:06 UTC (permalink / raw)
To: user-mode-linux-devel; +Cc: Jeff Dike
Alle 22:16, lunedì 15 marzo 2004, Jeff Dike ha scritto:
> On Mon, Mar 15, 2004 at 02:23:14PM -0600, Adam Heath wrote:
> > It doesn't.
>
> Figures.
>
> > It'd be nice if there was a generic device mapper between UML and the
> > host, so any device could be proxied, block or char.
>
> Yeah, that would be a good plan. Too bad about kbuild though.
Sorry, just add an hidden CONFIG_ option which is "default y unless UM" (in
2.6 language) and you've done the job for the single /dev/random thing (which
you spoke about above).
For the general proxy case, the hack would be to no-opify the
register_{blk,chr}dev for the majors/minors you want to proxy and add
__register_*dev which does the job as always. And to add a list of
not-proxable majors, possibly, to avoid users proxying their tty's or such
silly things.
--
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&opÌk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-03-18 18:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-13 1:49 [uml-devel] /dev/random oddity Thomas Schwinge
2004-03-13 13:17 ` Sven 'Darkman' Michels
2004-03-13 15:12 ` Stephen D. Williams
2004-03-14 22:40 ` Matt Zimmerman
2004-03-15 19:37 ` Jeff Dike
[not found] ` <Pine.LNX.4.58.0403151422320.13832@gradall.private.brainfood.com>
2004-03-15 21:16 ` Jeff Dike
2004-03-18 19:06 ` BlaisorBlade
2004-03-15 19:41 ` Jeff Dike
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.