All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] random: fix rdrand mix-in
@ 2018-07-17 13:53 Arnd Bergmann
  2018-07-17 16:26 ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-07-17 13:53 UTC (permalink / raw)
  To: Theodore Ts'o, Arnd Bergmann, Greg Kroah-Hartman
  Cc: Jann Horn, Tobin C. Harding, Rasmus Villemoes, Eric Biggers,
	linux-kernel

The newly added arch_get_random_int() call was done incorrectly,
using the output only if rdrand hardware was /not/ available. The
compiler points out that the data is uninitialized in this case:

drivers/char/random.c: In function 'write_pool.constprop':
drivers/char/random.c:1912:11: error: 't' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This fixes the condition so we only use that data when it was
valid.

Fixes: 349ddb707fb7 ("random: mix rdrand with entropy sent in from userspace")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/char/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 283fe390e878..71660aef8c8c 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1907,7 +1907,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
 			return -EFAULT;
 
 		for (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) {
-			if (arch_get_random_int(&t))
+			if (!arch_get_random_int(&t))
 				continue;
 			buf[i] ^= t;
 		}
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-18  0:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-17 13:53 [PATCH] random: fix rdrand mix-in Arnd Bergmann
2018-07-17 16:26 ` Linus Torvalds
2018-07-17 20:26   ` Theodore Y. Ts'o
2018-07-18  0:01     ` Linus Torvalds
2018-07-17 20:37   ` Arnd Bergmann

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.