summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-05-22 06:25:35 +0200
committerAdrian Mangeac <Adrian.Mangeac@enea.com>2019-05-22 11:17:34 +0200
commit301dea2daaa37e2bce882c024ae910748f7246e5 (patch)
tree491cecdee4b2fae27e06609fa189cbb4a05ec79f
parent15562bca35796a4dca667df8a87181ffbeaafa12 (diff)
downloadenea-kernel-cache-301dea2daaa37e2bce882c024ae910748f7246e5.tar.gz
random: CVE-2018-1108
random: fix crng_ready() test Reference: https://nvd.nist.gov/vuln/detail/CVE-2018-1108 https://lkml.org/lkml/2018/4/12/711 Change-Id: I41a55b940d4edd6a46641173de23f39c00cbf6d6 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/CVE-2018-1108-random-fix-crng_ready-test.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/patches/cve/CVE-2018-1108-random-fix-crng_ready-test.patch b/patches/cve/CVE-2018-1108-random-fix-crng_ready-test.patch
new file mode 100644
index 0000000..7776557
--- /dev/null
+++ b/patches/cve/CVE-2018-1108-random-fix-crng_ready-test.patch
@@ -0,0 +1,84 @@
1From 6e513bc20ca63f594632eca4e1968791240b8f18 Mon Sep 17 00:00:00 2001
2From: Theodore Ts'o <tytso@mit.edu>
3Date: Wed, 11 Apr 2018 13:27:52 -0400
4Subject: [PATCH] random: fix crng_ready() test
5
6commit 43838a23a05fbd13e47d750d3dfd77001536dd33 upstream.
7
8The crng_init variable has three states:
9
100: The CRNG is not initialized at all
111: The CRNG has a small amount of entropy, hopefully good enough for
12 early-boot, non-cryptographical use cases
132: The CRNG is fully initialized and we are sure it is safe for
14 cryptographic use cases.
15
16The crng_ready() function should only return true once we are in the
17last state. This addresses CVE-2018-1108.
18
19CVE: CVE-2018-1108
20Upstream-Status: Backport [https://lkml.org/lkml/2018/4/12/711]
21
22Reported-by: Jann Horn <jannh@google.com>
23Fixes: e192be9d9a30 ("random: replace non-blocking pool...")
24Cc: stable@kernel.org # 4.8+
25Signed-off-by: Theodore Ts'o <tytso@mit.edu>
26Reviewed-by: Jann Horn <jannh@google.com>
27Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
29---
30 drivers/char/random.c | 10 +++++-----
31 1 file changed, 5 insertions(+), 5 deletions(-)
32
33diff --git a/drivers/char/random.c b/drivers/char/random.c
34index e88a5c61eaa1..d7dc9727bcf0 100644
35--- a/drivers/char/random.c
36+++ b/drivers/char/random.c
37@@ -427,7 +427,7 @@ struct crng_state primary_crng = {
38 * its value (from 0->1->2).
39 */
40 static int crng_init = 0;
41-#define crng_ready() (likely(crng_init > 0))
42+#define crng_ready() (likely(crng_init > 1))
43 static int crng_init_cnt = 0;
44 #define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE)
45 static void _extract_crng(struct crng_state *crng,
46@@ -793,7 +793,7 @@ static int crng_fast_load(const char *cp, size_t len)
47
48 if (!spin_trylock_irqsave(&primary_crng.lock, flags))
49 return 0;
50- if (crng_ready()) {
51+ if (crng_init != 0) {
52 spin_unlock_irqrestore(&primary_crng.lock, flags);
53 return 0;
54 }
55@@ -855,7 +855,7 @@ static void _extract_crng(struct crng_state *crng,
56 {
57 unsigned long v, flags;
58
59- if (crng_init > 1 &&
60+ if (crng_ready() &&
61 time_after(jiffies, crng->init_time + CRNG_RESEED_INTERVAL))
62 crng_reseed(crng, crng == &primary_crng ? &input_pool : NULL);
63 spin_lock_irqsave(&crng->lock, flags);
64@@ -1141,7 +1141,7 @@ void add_interrupt_randomness(int irq, int irq_flags)
65 fast_mix(fast_pool);
66 add_interrupt_bench(cycles);
67
68- if (!crng_ready()) {
69+ if (unlikely(crng_init == 0)) {
70 if ((fast_pool->count >= 64) &&
71 crng_fast_load((char *) fast_pool->pool,
72 sizeof(fast_pool->pool))) {
73@@ -2214,7 +2214,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
74 {
75 struct entropy_store *poolp = &input_pool;
76
77- if (!crng_ready()) {
78+ if (unlikely(crng_init == 0)) {
79 crng_fast_load(buffer, count);
80 return;
81 }
82--
832.20.1
84