aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/random.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cd888d4ee605..bd449ad52442 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1895,14 +1895,22 @@ static int
1895write_pool(struct entropy_store *r, const char __user *buffer, size_t count) 1895write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1896{ 1896{
1897 size_t bytes; 1897 size_t bytes;
1898 __u32 buf[16]; 1898 __u32 t, buf[16];
1899 const char __user *p = buffer; 1899 const char __user *p = buffer;
1900 1900
1901 while (count > 0) { 1901 while (count > 0) {
1902 int b, i = 0;
1903
1902 bytes = min(count, sizeof(buf)); 1904 bytes = min(count, sizeof(buf));
1903 if (copy_from_user(&buf, p, bytes)) 1905 if (copy_from_user(&buf, p, bytes))
1904 return -EFAULT; 1906 return -EFAULT;
1905 1907
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
1906 count -= bytes; 1914 count -= bytes;
1907 p += bytes; 1915 p += bytes;
1908 1916