From: Stephan Mueller <stephan.mueller@atsec.com>
To: lkml <linux-kernel@vger.kernel.org>
Subject: drivers/char/random.c: variable type mismatch
Date: Thu, 08 Nov 2012 01:32:38 +0100 [thread overview]
Message-ID: <509AFDA6.7070005@atsec.com> (raw)
Hi,
the function add_timer_randomness currently defines:
struct {
...
unsigned cycles;
...
} sample;
Cycles used to be of type cycles_t. The inline get_cycles that fills
cycles is still of type cycles_t.
Unsigned is 32 bit whereas get_cycles is 64 bit. This means that only
the lower 32 bits of get_cycles is used.
However, due to the fact that jiffies provides very few entropy, the
event value provides (almost) none, the majority of entropy comes from
the processor cycles. Assuming that the processor cycles increase once
per nanosecond, after 2**32 cycles (about 4 seconds), the counter wraps.
This now means that on a 32 bit system, the maximum theoretical entropy
that can be added by one event is always 32 bit. But it used to be
higher due to the 64 bit type.
Now granted, the entropy estimator only assigns 11 bits of heuristic
entropy per event as a maximum.
But why weaken the RNG? Unless there is a technical problem, I would
suggest changing the variable type of cycles into unsigned long, or
better back to cycles_t.
Ciao
Stephan
next reply other threads:[~2012-11-08 0:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-08 0:32 Stephan Mueller [this message]
2012-11-08 11:47 ` drivers/char/random.c: variable type mismatch Theodore Ts'o
2012-11-14 16:15 ` Stephan Mueller
2012-11-14 17:52 ` H. Peter Anvin
2012-11-14 17:58 ` Stephan Mueller
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=509AFDA6.7070005@atsec.com \
--to=stephan.mueller@atsec.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).