diff options
| author | Andreas Wellving <andreas.wellving@enea.com> | 2018-10-12 10:07:48 +0200 |
|---|---|---|
| committer | Adrian Dudau <Adrian.Dudau@enea.com> | 2018-10-16 17:36:40 +0200 |
| commit | 5023a54ce43defbd88563e270f490a6c61ccf852 (patch) | |
| tree | c1668577c4020fa55078e69f788382381048d85b /patches/cve | |
| parent | 70d96b74d700846ca3454a406629edff6f9edc04 (diff) | |
| download | enea-kernel-cache-5023a54ce43defbd88563e270f490a6c61ccf852.tar.gz | |
random: CVE-2018-1108
random: fix crng_ready() test
References:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.9.y&id=4dfb3442bb7e1fb80515df4a199ca5a7a8edf900
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2018-1108
Change-Id: I85eb1123d6a4c5ef2b8f113551ac02df667e839d
Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
Diffstat (limited to 'patches/cve')
| -rw-r--r-- | patches/cve/4.9.x.scc | 1 | ||||
| -rw-r--r-- | patches/cve/CVE-2018-1108-random-fix-crng_ready-test.patch | 81 |
2 files changed, 82 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc index 4b6ec00..4e5c57f 100644 --- a/patches/cve/4.9.x.scc +++ b/patches/cve/4.9.x.scc | |||
| @@ -14,3 +14,4 @@ patch CVE-2018-1130-dccp-check-sk-for-closed-state-in-dccp_sendmsg.patch | |||
| 14 | 14 | ||
| 15 | #CVEs fixed in 4.9.96: | 15 | #CVEs fixed in 4.9.96: |
| 16 | patch CVE-2018-1092-ext4-fail-ext4_iget-for-root-directory-if-unallocate.patch | 16 | patch CVE-2018-1092-ext4-fail-ext4_iget-for-root-directory-if-unallocate.patch |
| 17 | patch CVE-2018-1108-random-fix-crng_ready-test.patch | ||
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..63e63c1 --- /dev/null +++ b/patches/cve/CVE-2018-1108-random-fix-crng_ready-test.patch | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | From 43838a23a05fbd13e47d750d3dfd77001536dd33 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Theodore Ts'o <tytso@mit.edu> | ||
| 3 | Date: Wed, 11 Apr 2018 13:27:52 -0400 | ||
| 4 | Subject: [PATCH] random: fix crng_ready() test | ||
| 5 | |||
| 6 | The crng_init variable has three states: | ||
| 7 | |||
| 8 | 0: The CRNG is not initialized at all | ||
| 9 | 1: The CRNG has a small amount of entropy, hopefully good enough for | ||
| 10 | early-boot, non-cryptographical use cases | ||
| 11 | 2: The CRNG is fully initialized and we are sure it is safe for | ||
| 12 | cryptographic use cases. | ||
| 13 | |||
| 14 | The crng_ready() function should only return true once we are in the | ||
| 15 | last state. This addresses CVE-2018-1108. | ||
| 16 | |||
| 17 | CVE: CVE-2018-1108 | ||
| 18 | Upstream-Status: Backport | ||
| 19 | |||
| 20 | Reported-by: Jann Horn <jannh@google.com> | ||
| 21 | Fixes: e192be9d9a30 ("random: replace non-blocking pool...") | ||
| 22 | Cc: stable@kernel.org # 4.8+ | ||
| 23 | Signed-off-by: Theodore Ts'o <tytso@mit.edu> | ||
| 24 | Reviewed-by: Jann Horn <jannh@google.com> | ||
| 25 | Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> | ||
| 26 | --- | ||
| 27 | drivers/char/random.c | 10 +++++----- | ||
| 28 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
| 29 | |||
| 30 | diff --git a/drivers/char/random.c b/drivers/char/random.c | ||
| 31 | index e027e7f..c8ec1e7 100644 | ||
| 32 | --- a/drivers/char/random.c | ||
| 33 | +++ b/drivers/char/random.c | ||
| 34 | @@ -427,7 +427,7 @@ struct crng_state primary_crng = { | ||
| 35 | * its value (from 0->1->2). | ||
| 36 | */ | ||
| 37 | static int crng_init = 0; | ||
| 38 | -#define crng_ready() (likely(crng_init > 0)) | ||
| 39 | +#define crng_ready() (likely(crng_init > 1)) | ||
| 40 | static int crng_init_cnt = 0; | ||
| 41 | #define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE) | ||
| 42 | static void _extract_crng(struct crng_state *crng, | ||
| 43 | @@ -794,7 +794,7 @@ static int crng_fast_load(const char *cp, size_t len) | ||
| 44 | |||
| 45 | if (!spin_trylock_irqsave(&primary_crng.lock, flags)) | ||
| 46 | return 0; | ||
| 47 | - if (crng_ready()) { | ||
| 48 | + if (crng_init != 0) { | ||
| 49 | spin_unlock_irqrestore(&primary_crng.lock, flags); | ||
| 50 | return 0; | ||
| 51 | } | ||
| 52 | @@ -856,7 +856,7 @@ static void _extract_crng(struct crng_state *crng, | ||
| 53 | { | ||
| 54 | unsigned long v, flags; | ||
| 55 | |||
| 56 | - if (crng_init > 1 && | ||
| 57 | + if (crng_ready() && | ||
| 58 | time_after(jiffies, crng->init_time + CRNG_RESEED_INTERVAL)) | ||
| 59 | crng_reseed(crng, crng == &primary_crng ? &input_pool : NULL); | ||
| 60 | spin_lock_irqsave(&crng->lock, flags); | ||
| 61 | @@ -1139,7 +1139,7 @@ void add_interrupt_randomness(int irq, int irq_flags) | ||
| 62 | fast_mix(fast_pool); | ||
| 63 | add_interrupt_bench(cycles); | ||
| 64 | |||
| 65 | - if (!crng_ready()) { | ||
| 66 | + if (unlikely(crng_init == 0)) { | ||
| 67 | if ((fast_pool->count >= 64) && | ||
| 68 | crng_fast_load((char *) fast_pool->pool, | ||
| 69 | sizeof(fast_pool->pool))) { | ||
| 70 | @@ -2212,7 +2212,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, | ||
| 71 | { | ||
| 72 | struct entropy_store *poolp = &input_pool; | ||
| 73 | |||
| 74 | - if (!crng_ready()) { | ||
| 75 | + if (unlikely(crng_init == 0)) { | ||
| 76 | crng_fast_load(buffer, count); | ||
| 77 | return; | ||
| 78 | } | ||
| 79 | -- | ||
| 80 | |||
| 81 | |||
