FAILED: patch "[PATCH] crypto: testmgr - skip crc32c context test for ahash" failed to apply to 4.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From eb5e6730db98fcc4b51148b4a819fa4bf864ae54 Mon Sep 17 00:00:00 2001
From: Eric Biggers <[email protected]>
Date: Wed, 23 Jan 2019 20:57:35 -0800
Subject: [PATCH] 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.)
crypto/testmgr.c +10 -4
@@ -1909,14 +1909,21 @@ static int alg_test_crc32c(const struct alg_test_desc *desc, err =alg_test_hash (desc, driver, type, mask);if (err) - goto out; +return err; tfm =crypto_alloc_shash (driver, type, mask);if (IS_ERR (tfm)) { +if (PTR_ERR (tfm) == -ENOENT ) { +/* +* This crc32c implementation is only available through +* ahash API, not the shash API, so the remaining part +* of the test is not applicable to it. +*/ +return 0 ; + }printk (KERN_ERR "alg: crc32c: Failed to load transform for %s: " "%ld\n" , driver,PTR_ERR (tfm)); - err =PTR_ERR (tfm); - goto out; +return PTR_ERR (tfm); } do {
@@ -1943,7 +1950,6 @@ static int alg_test_crc32c(const struct alg_test_desc *desc,crypto_free_shash (tfm); -out:return err; }
PATCH 1/1 crypto: pcbc - remove bogus memcpy()s with src == dest
From: Eric Biggers <[email protected]>
commit 251b7aea34ba3c4d4fdfa9447695642eb8b8b098 upstream
The memcpy()s in the PCBC implementation use walk->iv as both the source and destination, which has undefined behavior. These memcpy()'s are actually unneeded, because walk->iv is already used to hold the previous plaintext block XOR'd with the previous ciphertext block. Thus, walk->iv is already updated to its final value.
So remove the broken and unnecessary memcpy()s.
--- crypto/pcbc.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
crypto/pcbc.c +4 -10
@@ -52,7 +52,7 @@ static int crypto_pcbc_encrypt_segment(struct blkcipher_desc *desc,unsigned int nbytes = walk->nbytes;u8 *src = walk->src.virt.addr;u8 *dst = walk->dst.virt.addr; -u8 *iv = walk->iv; +u8 *const iv = walk->iv; do { crypto_xor(iv, src, bsize);
@@ -76,7 +76,7 @@ static int crypto_pcbc_encrypt_inplace(struct blkcipher_desc *desc,int bsize =crypto_cipher_blocksize (tfm);unsigned int nbytes = walk->nbytes;u8 *src = walk->src.virt.addr; -u8 *iv = walk->iv; +u8 *const iv = walk->iv;u8 tmpbuf[bsize]; do {
@@ -89,8 +89,6 @@ static int crypto_pcbc_encrypt_inplace(struct blkcipher_desc *desc, src += bsize; }while ((nbytes -= bsize) >= bsize); -memcpy (walk->iv, iv, bsize); -return nbytes; }
@@ -130,7 +128,7 @@ static int crypto_pcbc_decrypt_segment(struct blkcipher_desc *desc,unsigned int nbytes = walk->nbytes;u8 *src = walk->src.virt.addr;u8 *dst = walk->dst.virt.addr; -u8 *iv = walk->iv; +u8 *const iv = walk->iv; do { fn(crypto_cipher_tfm(tfm), dst, src);
@@ -142,8 +140,6 @@ static int crypto_pcbc_decrypt_segment(struct blkcipher_desc *desc, dst += bsize; }while ((nbytes -= bsize) >= bsize); -memcpy (walk->iv, iv, bsize); -return nbytes; }
@@ -156,7 +152,7 @@ static int crypto_pcbc_decrypt_inplace(struct blkcipher_desc *desc,int bsize =crypto_cipher_blocksize (tfm);unsigned int nbytes = walk->nbytes;u8 *src = walk->src.virt.addr; -u8 *iv = walk->iv; +u8 *const iv = walk->iv;u8 tmpbuf[bsize]; do {
@@ -169,8 +165,6 @@ static int crypto_pcbc_decrypt_inplace(struct blkcipher_desc *desc, src += bsize; }while ((nbytes -= bsize) >= bsize); -memcpy (walk->iv, iv, bsize); -return nbytes; }
Signature · 1 line
2.21.0