diff options
-rw-r--r-- | patches/cve/CVE-2017-18075-crypto-pcrypt-fix-freeing-pcrypt-instances.patch | 84 |
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 @@ | |||
1 | From 7156c794b8ab462705e6ac80c5fa69565eb44c62 Mon Sep 17 00:00:00 2001 | ||
2 | From: Eric Biggers <ebiggers@google.com> | ||
3 | Date: Wed, 20 Dec 2017 14:28:25 -0800 | ||
4 | Subject: [PATCH] crypto: pcrypt - fix freeing pcrypt instances | ||
5 | |||
6 | commit d76c68109f37cb85b243a1cf0f40313afd2bae68 upstream. | ||
7 | |||
8 | pcrypt is using the old way of freeing instances, where the ->free() | ||
9 | method specified in the 'struct crypto_template' is passed a pointer to | ||
10 | the 'struct crypto_instance'. But the crypto_instance is being | ||
11 | kfree()'d directly, which is incorrect because the memory was actually | ||
12 | allocated as an aead_instance, which contains the crypto_instance at a | ||
13 | nonzero offset. Thus, the wrong pointer was being kfree()'d. | ||
14 | |||
15 | Fix 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 | |||
18 | CVE: CVE-2017-18075 | ||
19 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=7156c794b8ab462705e6ac80c5fa69565eb44c62] | ||
20 | |||
21 | Reported-by: syzbot <syzkaller@googlegroups.com> | ||
22 | Fixes: 0496f56065e0 ("crypto: pcrypt - Add support for new AEAD interface") | ||
23 | Signed-off-by: Eric Biggers <ebiggers@google.com> | ||
24 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> | ||
25 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
26 | Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> | ||
27 | --- | ||
28 | crypto/pcrypt.c | 19 ++++++++++--------- | ||
29 | 1 file changed, 10 insertions(+), 9 deletions(-) | ||
30 | |||
31 | diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c | ||
32 | index 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 | -- | ||
83 | 2.20.1 | ||
84 | |||