1
0
Fork 0
alistair23-linux/drivers/crypto/ccp
John Allen 28bd8f392f crypto: ccp - Fix use of merged scatterlists
commit 8a302808c6 upstream.

Running the crypto manager self tests with
CONFIG_CRYPTO_MANAGER_EXTRA_TESTS may result in several types of errors
when using the ccp-crypto driver:

alg: skcipher: cbc-des3-ccp encryption failed on test vector 0; expected_error=0, actual_error=-5 ...

alg: skcipher: ctr-aes-ccp decryption overran dst buffer on test vector 0 ...

alg: ahash: sha224-ccp test failed (wrong result) on test vector ...

These errors are the result of improper processing of scatterlists mapped
for DMA.

Given a scatterlist in which entries are merged as part of mapping the
scatterlist for DMA, the DMA length of a merged entry will reflect the
combined length of the entries that were merged. The subsequent
scatterlist entry will contain DMA information for the scatterlist entry
after the last merged entry, but the non-DMA information will be that of
the first merged entry.

The ccp driver does not take this scatterlist merging into account. To
address this, add a second scatterlist pointer to track the current
position in the DMA mapped representation of the scatterlist. Both the DMA
representation and the original representation of the scatterlist must be
tracked as while most of the driver can use just the DMA representation,
scatterlist_map_and_copy() must use the original representation and
expects the scatterlist pointer to be accurate to the original
representation.

In order to properly walk the original scatterlist, the scatterlist must
be walked until the combined lengths of the entries seen is equal to the
DMA length of the current entry being processed in the DMA mapped
representation.

Fixes: 63b945091a ("crypto: ccp - CCP device driver and interface support")
Signed-off-by: John Allen <john.allen@amd.com>
Cc: stable@vger.kernel.org
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-19 08:16:28 +02:00
..
Kconfig crypto: ccp -- don't "select" CONFIG_DMADEVICES 2020-06-22 09:30:50 +02:00
Makefile crypto: ccp - Make CCP debugfs support optional 2019-07-26 22:08:03 +10:00
ccp-crypto-aes-cmac.c crypto: ccp - move to AES library for CMAC key derivation 2019-07-26 14:58:13 +10:00
ccp-crypto-aes-galois.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-08-09 09:17:05 -07:00
ccp-crypto-aes-xts.c crypto: ccp - invoke fallback for XTS ciphertext stealing 2019-08-30 18:05:31 +10:00
ccp-crypto-aes.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-07-08 20:57:08 -07:00
ccp-crypto-des3.c crypto: ccp/des - switch to new verification routines 2019-08-22 14:39:39 +10:00
ccp-crypto-main.c crypto: ccp - Log an error message when ccp-crypto fails to load 2019-08-09 15:05:32 +10:00
ccp-crypto-rsa.c crypto: ccp - Switch to SPDX license identifiers 2019-07-03 22:13:12 +08:00
ccp-crypto-sha.c crypto: ccp - Switch to SPDX license identifiers 2019-07-03 22:13:12 +08:00
ccp-crypto.h crypto: ccp - Remove unnecessary linux/pci.h include 2019-08-09 15:12:30 +10:00
ccp-debugfs.c crypto: ccp - Switch to SPDX license identifiers 2019-07-03 22:13:12 +08:00
ccp-dev-v3.c crypto: ccp - set max RSA modulus size for v3 platform devices as well 2020-02-11 04:35:30 -08:00
ccp-dev-v5.c crypto: ccp - Remove unnecessary linux/pci.h include 2019-08-09 15:12:30 +10:00
ccp-dev.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-09-18 12:11:14 -07:00
ccp-dev.h crypto: ccp - Fix use of merged scatterlists 2020-08-19 08:16:28 +02:00
ccp-dmaengine.c crypto: ccp - fix uninitialized list head 2019-12-13 08:43:08 +01:00
ccp-ops.c crypto: ccp - Fix use of merged scatterlists 2020-08-19 08:16:28 +02:00
psp-dev.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-07-19 12:23:37 -07:00
psp-dev.h crypto: ccp - Remove unnecessary linux/pci.h include 2019-08-09 15:12:30 +10:00
sp-dev.c crypto: ccp - Switch to SPDX license identifiers 2019-07-03 22:13:12 +08:00
sp-dev.h crypto: ccp - Remove unnecessary linux/pci.h include 2019-08-09 15:12:30 +10:00
sp-pci.c crypto: ccp - Switch to SPDX license identifiers 2019-07-03 22:13:12 +08:00
sp-platform.c crypto: ccp - use devm_platform_ioremap_resource() to simplify code 2019-08-09 15:11:59 +10:00