All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@turbolabs.com>
To: Horst von Brand <vonbrand@sleipnir.valparaiso.cl>,
	"Theodore Ts'o" <tytso@mit.edu>,
	torvalds@transmeta.com, Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] MAJOR random.c bugfix
Date: Sun, 28 Oct 2001 22:46:16 -0700	[thread overview]
Message-ID: <20011028224616.H1311@lynx.no> (raw)
In-Reply-To: <adilger@turbolabs.com> <200110282357.f9SNv2kD011923@sleipnir.valparaiso.cl>
In-Reply-To: <200110282357.f9SNv2kD011923@sleipnir.valparaiso.cl>; from vonbrand@sleipnir.valparaiso.cl on Sun, Oct 28, 2001 at 08:57:02PM -0300

On Oct 28, 2001  20:57 -0300, Horst von Brand wrote:
> I have now seen various bits and pieces about this flying around. To get it
> right will be hard, as over/under estimates will show up only under unusual
> circumstances; and as you _can't_ really know how much "entropy" there
> should be, testing this is very hard.  So the only way to get it right is
> make it "obviously" right.

                ********** LATE BREAKING NEWS ***********

Is add_entropy_words() broken for multi-word input???  That would be very bad.
In one most cases we are only dealing with two word inputs, but is really bad
where it counts - transferring values to the secondary pool, which is where
we really get data from for /dev/random.

It appears that we repeatedly add the first word to the entropy pool, no
matter how many words are passed!!!  I checked the kernel CVS repository,
and it has been like this since a big change in 2.3.16.  Ugh!!!

http://innominate.org/cgi-bin/lksr/linux/drivers/char/random.c.diff?r1=1.1.1.4&r2=1.1.1.5&cvsroot=v2.3

Is there something I'm missing?  Even in the 2.3.16 version, we never
change "in" from its initial value, so we only use the first input word.
The older (2.2, 2.3.15-) code had it correct, in that it explicitly worked
on both of the input words.

A quick patch to fix this is below.

Cheers, Andreas

PS: what's up with new_rotate?  Why not just do it like:
	r->input_rotate = (r->input_rotate + (i ? 7 : 14)) & 31;

===========================================================================
--- linux/drivers/char/random.c.old	Sun Oct 28 22:26:31 2001
+++ linux/drivers/char/random.c	Sun Oct 28 22:25:11 2001
@@ -564,7 +564,7 @@
 	__u32 w;
 
 	while (nwords--) {
-		w = rotate_left(r->input_rotate, *in);
+		w = rotate_left(r->input_rotate, *in++);
 		i = r->add_ptr = (r->add_ptr - 1) & wordmask;
 		/*
 		 * Normally, we add 7 bits of rotation to the pool.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/


      parent reply	other threads:[~2001-10-29  5:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-27  4:21 [PATCH] random.c bugfix René Scharfe
2001-10-27  6:21 ` Andreas Dilger
2001-10-27  6:35   ` Robert Love
2001-10-28 23:57   ` Horst von Brand
2001-10-29  5:37     ` Andreas Dilger
2001-10-29 16:15       ` Horst von Brand
2001-10-29 16:58         ` Oliver Xymoron
2001-10-29 23:39           ` Andreas Dilger
2001-10-30  0:23             ` Oliver Xymoron
2001-10-30  3:50               ` Andreas Dilger
2001-10-30 16:07                 ` Theodore Tso
2001-10-31  6:19                   ` Andreas Dilger
2001-10-31 14:42                     ` Oliver Xymoron
2001-10-30  4:49               ` Andreas Dilger
2001-10-29  5:46     ` Andreas Dilger [this message]

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=20011028224616.H1311@lynx.no \
    --to=adilger@turbolabs.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=tytso@mit.edu \
    --cc=vonbrand@sleipnir.valparaiso.cl \
    /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.