Fix thinko in get_random_bytes().

This commit is contained in:
Dave Jones 2011-11-16 15:59:46 -05:00
parent c8de25547e
commit f42441ac99
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,40 @@
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
Message-Id: <4ec4061010261a4cb0@agluck-desktop.sc.intel.com>
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;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

View File

@ -635,6 +635,8 @@ Patch3500: jbd-jbd2-validate-sb-s_first-in-journal_get_superblo.patch
#rhbz 753236
Patch4000: nfsv4-include-bitmap-in-nfsv4_get_acl_data.patch
Patch10000: get_random_bytes-consecutive-words.patch
# patches headed upstream
Patch12010: add-appleir-usb-driver.patch
@ -1219,6 +1221,8 @@ ApplyPatch disable-i8042-check-on-apple-mac.patch
ApplyPatch add-appleir-usb-driver.patch
ApplyPatch get_random_bytes-consecutive-words.patch
ApplyPatch udlfb-bind-framebuffer-to-interface.patch
ApplyPatch epoll-limit-paths.patch
ApplyPatch rcu-avoid-just-onlined-cpu-resched.patch
@ -1885,6 +1889,9 @@ fi
# and build.
%changelog
* Wed Nov 16 2011 Dave Jones <davej@redhat.com>
- Fix thinko in get_random_bytes().
* Wed Nov 16 2011 Kyle McMartin <kmcmartin@redhat.com>
- Work around #663080 on s390x and restore building perf there.