summaryrefslogtreecommitdiffstats
path: root/crypto/testmgr.c
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-01-23 23:57:35 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2019-02-01 01:42:04 -0500
commiteb5e6730db98fcc4b51148b4a819fa4bf864ae54 (patch)
treeb5f9e89206e4c3f314d8aba57c1b402b6ccca82b /crypto/testmgr.c
parent341a64c7e69f54e319ac187721b342f7620af6d6 (diff)
crypto: testmgr - skip crc32c context test for ahash algorithms
Instantiating "cryptd(crc32c)" causes a crypto self-test failure because the crypto_alloc_shash() in alg_test_crc32c() fails. This is because cryptd(crc32c) is an ahash algorithm, not a shash algorithm; so it can only be accessed through the ahash API, unlike shash algorithms which can be accessed through both the ahash and shash APIs. As the test is testing the shash descriptor format which is only applicable to shash algorithms, skip it for ahash algorithms. (Note that it's still important to fix crypto self-test failures even for weird algorithm instantiations like cryptd(crc32c) that no one would really use; in fips_enabled mode unprivileged users can use them to panic the kernel, and also they prevent treating a crypto self-test failure as a bug when fuzzing the kernel.) Fixes: 8e3ee85e68c5 ("crypto: crc32c - Test descriptor context format") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r--crypto/testmgr.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 4ac3d22256c3..a73455b543ad 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1909,14 +1909,21 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
1909 1909
1910 err = alg_test_hash(desc, driver, type, mask); 1910 err = alg_test_hash(desc, driver, type, mask);
1911 if (err) 1911 if (err)
1912 goto out; 1912 return err;
1913 1913
1914 tfm = crypto_alloc_shash(driver, type, mask); 1914 tfm = crypto_alloc_shash(driver, type, mask);
1915 if (IS_ERR(tfm)) { 1915 if (IS_ERR(tfm)) {
1916 if (PTR_ERR(tfm) == -ENOENT) {
1917 /*
1918 * This crc32c implementation is only available through
1919 * ahash API, not the shash API, so the remaining part
1920 * of the test is not applicable to it.
1921 */
1922 return 0;
1923 }
1916 printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: " 1924 printk(KERN_ERR "alg: crc32c: Failed to load transform for %s: "
1917 "%ld\n", driver, PTR_ERR(tfm)); 1925 "%ld\n", driver, PTR_ERR(tfm));
1918 err = PTR_ERR(tfm); 1926 return PTR_ERR(tfm);
1919 goto out;
1920 } 1927 }
1921 1928
1922 do { 1929 do {
@@ -1943,7 +1950,6 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,
1943 1950
1944 crypto_free_shash(tfm); 1951 crypto_free_shash(tfm);
1945 1952
1946out:
1947 return err; 1953 return err;
1948} 1954}
1949 1955