mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "Theodore Ts'o" <tytso@mit.edu>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jann Horn <jannh@google.com>, "Tobin C. Harding" <me@tobin.cc>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Eric Biggers <ebiggers@google.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] random: fix rdrand mix-in
Date: Tue, 17 Jul 2018 15:53:00 +0200	[thread overview]
Message-ID: <20180717135307.3713325-1-arnd@arndb.de> (raw)

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


             reply	other threads:[~2018-07-17 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 13:53 Arnd Bergmann [this message]
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

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=20180717135307.3713325-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=ebiggers@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=me@tobin.cc \
    --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

all inboxes | Powered by JetHome®