summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2019-05-21 15:16:55 +0200
committerAdrian Mangeac <Adrian.Mangeac@enea.com>2019-05-21 17:20:18 +0200
commit7ce41950deb2bac0c1e4d4ff7a0771228e5dfa5f (patch)
tree188b49de8a57ee466265a4a2bac272e9c0a48039
parentd5e3ea804e799cd30764c340477504501c108fcb (diff)
downloadenea-kernel-cache-7ce41950deb2bac0c1e4d4ff7a0771228e5dfa5f.tar.gz
crypto: CVE-2017-18075
crypto: pcrypt - fix freeing pcrypt instances Reference: https://nvd.nist.gov/vuln/detail/CVE-2017-18075 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=7156c794b8ab462705e6ac80c5fa69565eb44c62 Change-Id: I677805222830347c537d4400c6c78f4ff7783c0d Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
-rw-r--r--patches/cve/CVE-2017-18075-crypto-pcrypt-fix-freeing-pcrypt-instances.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/patches/cve/CVE-2017-18075-crypto-pcrypt-fix-freeing-pcrypt-instances.patch b/patches/cve/CVE-2017-18075-crypto-pcrypt-fix-freeing-pcrypt-instances.patch
new file mode 100644
index 0000000..f842da8
--- /dev/null
+++ b/patches/cve/CVE-2017-18075-crypto-pcrypt-fix-freeing-pcrypt-instances.patch
@@ -0,0 +1,84 @@
1From 7156c794b8ab462705e6ac80c5fa69565eb44c62 Mon Sep 17 00:00:00 2001
2From: Eric Biggers <ebiggers@google.com>
3Date: Wed, 20 Dec 2017 14:28:25 -0800
4Subject: [PATCH] crypto: pcrypt - fix freeing pcrypt instances
5
6commit d76c68109f37cb85b243a1cf0f40313afd2bae68 upstream.
7
8pcrypt is using the old way of freeing instances, where the ->free()
9method specified in the 'struct crypto_template' is passed a pointer to
10the 'struct crypto_instance'. But the crypto_instance is being
11kfree()'d directly, which is incorrect because the memory was actually
12allocated as an aead_instance, which contains the crypto_instance at a
13nonzero offset. Thus, the wrong pointer was being kfree()'d.
14
15Fix it by switching to the new way to free aead_instance's where the
16->free() method is specified in the aead_instance itself.
17
18CVE: CVE-2017-18075
19Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=7156c794b8ab462705e6ac80c5fa69565eb44c62]
20
21Reported-by: syzbot <syzkaller@googlegroups.com>
22Fixes: 0496f56065e0 ("crypto: pcrypt - Add support for new AEAD interface")
23Signed-off-by: Eric Biggers <ebiggers@google.com>
24Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
25Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
27---
28 crypto/pcrypt.c | 19 ++++++++++---------
29 1 file changed, 10 insertions(+), 9 deletions(-)
30
31diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
32index ee9cfb99fe25..f8ec3d4ba4a8 100644
33--- a/crypto/pcrypt.c
34+++ b/crypto/pcrypt.c
35@@ -254,6 +254,14 @@ static void pcrypt_aead_exit_tfm(struct crypto_aead *tfm)
36 crypto_free_aead(ctx->child);
37 }
38
39+static void pcrypt_free(struct aead_instance *inst)
40+{
41+ struct pcrypt_instance_ctx *ctx = aead_instance_ctx(inst);
42+
43+ crypto_drop_aead(&ctx->spawn);
44+ kfree(inst);
45+}
46+
47 static int pcrypt_init_instance(struct crypto_instance *inst,
48 struct crypto_alg *alg)
49 {
50@@ -319,6 +327,8 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb,
51 inst->alg.encrypt = pcrypt_aead_encrypt;
52 inst->alg.decrypt = pcrypt_aead_decrypt;
53
54+ inst->free = pcrypt_free;
55+
56 err = aead_register_instance(tmpl, inst);
57 if (err)
58 goto out_drop_aead;
59@@ -349,14 +359,6 @@ static int pcrypt_create(struct crypto_template *tmpl, struct rtattr **tb)
60 return -EINVAL;
61 }
62
63-static void pcrypt_free(struct crypto_instance *inst)
64-{
65- struct pcrypt_instance_ctx *ctx = crypto_instance_ctx(inst);
66-
67- crypto_drop_aead(&ctx->spawn);
68- kfree(inst);
69-}
70-
71 static int pcrypt_cpumask_change_notify(struct notifier_block *self,
72 unsigned long val, void *data)
73 {
74@@ -469,7 +471,6 @@ static void pcrypt_fini_padata(struct padata_pcrypt *pcrypt)
75 static struct crypto_template pcrypt_tmpl = {
76 .name = "pcrypt",
77 .create = pcrypt_create,
78- .free = pcrypt_free,
79 .module = THIS_MODULE,
80 };
81
82--
832.20.1
84