Skip to content

Commit 81e69df

Browse files
committed
random: mix rdrand with entropy sent in from userspace
Fedora has integrated the jitter entropy daemon to work around slow boot problems, especially on VM's that don't support virtio-rng: https://bugzilla.redhat.com/show_bug.cgi?id=1572944 It's understandable why they did this, but the Jitter entropy daemon works fundamentally on the principle: "the CPU microarchitecture is **so** complicated and we can't figure it out, so it *must* be random". Yes, it uses statistical tests to "prove" it is secure, but AES_ENCRYPT(NSA_KEY, COUNTER++) will also pass statistical tests with flying colors. So if RDRAND is available, mix it into entropy submitted from userspace. It can't hurt, and if you believe the NSA has backdoored RDRAND, then they probably have enough details about the Intel microarchitecture that they can reverse engineer how the Jitter entropy daemon affects the microarchitecture, and attack its output stream. And if RDRAND is in fact an honest DRNG, it will immeasurably improve on what the Jitter entropy daemon might produce. This also provides some protection against someone who is able to read or set the entropy seed file. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org Cc: Arnd Bergmann <arnd@arndb.de>
1 parent 1e4b044 commit 81e69df

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/char/random.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,14 +1895,22 @@ static int
18951895
write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
18961896
{
18971897
size_t bytes;
1898-
__u32 buf[16];
1898+
__u32 t, buf[16];
18991899
const char __user *p = buffer;
19001900

19011901
while (count > 0) {
1902+
int b, i = 0;
1903+
19021904
bytes = min(count, sizeof(buf));
19031905
if (copy_from_user(&buf, p, bytes))
19041906
return -EFAULT;
19051907

1908+
for (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) {
1909+
if (!arch_get_random_int(&t))
1910+
break;
1911+
buf[i] ^= t;
1912+
}
1913+
19061914
count -= bytes;
19071915
p += bytes;
19081916

0 commit comments

Comments
 (0)