]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.31/crypto-testmgr-skip-crc32c-context-test-for-ahash-algorithms.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / crypto-testmgr-skip-crc32c-context-test-for-ahash-algorithms.patch
1 From eb5e6730db98fcc4b51148b4a819fa4bf864ae54 Mon Sep 17 00:00:00 2001
2 From: Eric Biggers <ebiggers@google.com>
3 Date: Wed, 23 Jan 2019 20:57:35 -0800
4 Subject: crypto: testmgr - skip crc32c context test for ahash algorithms
5
6 From: Eric Biggers <ebiggers@google.com>
7
8 commit eb5e6730db98fcc4b51148b4a819fa4bf864ae54 upstream.
9
10 Instantiating "cryptd(crc32c)" causes a crypto self-test failure because
11 the crypto_alloc_shash() in alg_test_crc32c() fails. This is because
12 cryptd(crc32c) is an ahash algorithm, not a shash algorithm; so it can
13 only be accessed through the ahash API, unlike shash algorithms which
14 can be accessed through both the ahash and shash APIs.
15
16 As the test is testing the shash descriptor format which is only
17 applicable to shash algorithms, skip it for ahash algorithms.
18
19 (Note that it's still important to fix crypto self-test failures even
20 for weird algorithm instantiations like cryptd(crc32c) that no one
21 would really use; in fips_enabled mode unprivileged users can use them
22 to panic the kernel, and also they prevent treating a crypto self-test
23 failure as a bug when fuzzing the kernel.)
24
25 Fixes: 8e3ee85e68c5 ("crypto: crc32c - Test descriptor context format")
26 Cc: stable@vger.kernel.org
27 Signed-off-by: Eric Biggers <ebiggers@google.com>
28 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30
31 ---
32 crypto/testmgr.c | 14 ++++++++++----
33 1 file changed, 10 insertions(+), 4 deletions(-)
34
35 --- a/crypto/testmgr.c
36 +++ b/crypto/testmgr.c
37 @@ -1894,14 +1894,21 @@ static int alg_test_crc32c(const struct
38
39 err = alg_test_hash(desc, driver, type, mask);
40 if (err)
41 - goto out;
42 + return err;
43
44 tfm = crypto_alloc_shash(driver, type, mask);
45 if (IS_ERR(tfm)) {
46 + if (PTR_ERR(tfm) == -ENOENT) {
47 + /*
48 + * This crc32c implementation is only available through
49 + * ahash API, not the shash API, so the remaining part
50 + * of the test is not applicable to it.
51 + */
52 + return 0;
53 + }
54 printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
55 "%ld\n", driver, PTR_ERR(tfm));
56 - err = PTR_ERR(tfm);
57 - goto out;
58 + return PTR_ERR(tfm);
59 }
60
61 do {
62 @@ -1928,7 +1935,6 @@ static int alg_test_crc32c(const struct
63
64 crypto_free_shash(tfm);
65
66 -out:
67 return err;
68 }
69