[kernel/f15] Fix thinko in get_random_bytes().

Dave Jones davej at fedoraproject.org
Wed Nov 16 20:59:54 UTC 2011


commit f42441ac992e8e4451b60e50534ca8b6c2814cd2
Author: Dave Jones <davej at redhat.com>
Date:   Wed Nov 16 15:59:46 2011 -0500

    Fix thinko in get_random_bytes().

 get_random_bytes-consecutive-words.patch |   40 ++++++++++++++++++++++++++++++
 kernel.spec                              |    7 +++++
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/get_random_bytes-consecutive-words.patch b/get_random_bytes-consecutive-words.patch
new file mode 100644
index 0000000..9c70424
--- /dev/null
+++ b/get_random_bytes-consecutive-words.patch
@@ -0,0 +1,40 @@
+From: "Luck, Tony" <tony.luck at intel.com>
+To: Linus Torvalds <torvalds at linux-foundation.org>,
+        "H. Peter Anvin" <hpa at zytor.com>, Ingo Molnar <mingo at elte.hu>,
+        Thomas Gleixner <tglx at linutronix.de>,
+        Fenghua Yu <fenghua.yu at intel.com>, Matt Mackall <mpm at selenic.com>,
+        Herbert Xu <herbert at gondor.hengli.com.au>,
+        "Theodore Ts'o" <tytso at mit.edu>, Jeff Garzik <jgarzik at pobox.com>,
+        Arjan van de Ven <arjan at linux.intel.com>, linux-kernel at vger.kernel.org
+Subject: [PATCH] fix typo/thinko in get_random_bytes()
+Date: 	Wed, 16 Nov 2011 10:50:56 -0800
+Message-Id: <4ec4061010261a4cb0 at 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 at 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 at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/
+
diff --git a/kernel.spec b/kernel.spec
index 28e8eb9..9794219 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -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 at redhat.com>
+- Fix thinko in get_random_bytes().
+
 * Wed Nov 16 2011 Kyle McMartin <kmcmartin at redhat.com>
 - Work around #663080 on s390x and restore building perf there.
 


More information about the scm-commits mailing list