From: "Luck, Tony" <tony.luck@intel.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>,
Thomas Gleixner <tglx@linutronix.de>,
Fenghua Yu <fenghua.yu@intel.com>, Matt Mackall <mpm@selenic.com>,
Herbert Xu <herbert@gondor.hengli.com.au>,
"Theodore Ts'o" <tytso@mit.edu>, Jeff Garzik <jgarzik@pobox.com>,
Arjan van de Ven <arjan@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] fix typo/thinko in get_random_bytes()
Date: Wed, 16 Nov 2011 10:50:56 -0800 [thread overview]
Message-ID: <4ec4061010261a4cb0@agluck-desktop.sc.intel.com> (raw)
If there is an architecture-specific random number generator we use
it to acquire randomness one "long" at a time. We should put these
random words into consecutive words in the result buffer - not just
overwrite the first word again and again.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 63e19ba..6035ab8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -941,7 +941,7 @@ void get_random_bytes(void *buf, int nbytes)
if (!arch_get_random_long(&v))
break;
- memcpy(buf, &v, chunk);
+ memcpy(p, &v, chunk);
p += chunk;
nbytes -= chunk;
}
next reply other threads:[~2011-11-16 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-16 18:50 Luck, Tony [this message]
2011-11-16 19:34 ` [PATCH] fix typo/thinko in get_random_bytes() H. Peter Anvin
2011-11-16 19:41 ` Thomas Gleixner
2011-11-17 16:34 ` H. Peter Anvin
2011-11-18 23:45 ` [tip:x86/urgent] random: Fix handing of arch_get_random_long " tip-bot for Luck, Tony
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=4ec4061010261a4cb0@agluck-desktop.sc.intel.com \
--to=tony.luck@intel.com \
--cc=arjan@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=herbert@gondor.hengli.com.au \
--cc=hpa@zytor.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mpm@selenic.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
/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