WSL2-Linux-Kernel/drivers/crypto/ccp
Maciej S. Szmigiero ee54953ecd crypto: ccp - return an actual key size from RSA max_size callback
commit 0a9eb80e64 upstream.

rsa-pkcs1pad uses a value returned from a RSA implementation max_size
callback as a size of an input buffer passed to the RSA implementation for
encrypt and sign operations.

CCP RSA implementation uses a hardware input buffer which size depends only
on the current RSA key length, so it should return this key length in
the max_size callback, too.
This also matches what the kernel software RSA implementation does.

Previously, the value returned from this callback was always the maximum
RSA key size the CCP hardware supports.
This resulted in this huge buffer being passed by rsa-pkcs1pad to CCP even
for smaller key sizes and then in a buffer overflow when ccp_run_rsa_cmd()
tried to copy this large input buffer into a RSA key length-sized hardware
input buffer.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Fixes: ceeec0afd6 ("crypto: ccp - Add support for RSA on the CCP")
Cc: stable@vger.kernel.org
Acked-by: Gary R Hook <gary.hook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-08 14:26:32 +02:00
..
Kconfig crypto: ccp - select CONFIG_CRYPTO_RSA 2017-08-09 20:17:59 +08:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ccp-crypto-aes-cmac.c crypto: ccp - Prevent information leakage on export 2016-04-15 22:13:56 +08:00
ccp-crypto-aes-galois.c crypto: ccp - Update copyright dates for 2017. 2017-07-28 17:58:01 +08:00
ccp-crypto-aes-xts.c crypto: ccp - Add XTS-AES-256 support for CCP version 5 2017-08-04 09:27:44 +08:00
ccp-crypto-aes.c crypto: ccp - CCP versioning support 2016-03-11 21:19:16 +08:00
ccp-crypto-des3.c crypto: ccp - Update copyright dates for 2017. 2017-07-28 17:58:01 +08:00
ccp-crypto-main.c crypto: ccp - Add support for RSA on the CCP 2017-07-28 17:58:05 +08:00
ccp-crypto-rsa.c crypto: ccp - return an actual key size from RSA max_size callback 2018-04-08 14:26:32 +02:00
ccp-crypto-sha.c crypto: ccp - Update copyright dates for 2017. 2017-07-28 17:58:01 +08:00
ccp-crypto.h crypto: ccp - Add XTS-AES-256 support for CCP version 5 2017-08-04 09:27:44 +08:00
ccp-debugfs.c crypto: ccp - Provide an error path for debugfs setup failure 2017-07-18 17:50:53 +08:00
ccp-dev-v3.c csrypto: ccp - Expand RSA support for a v5 ccp 2017-07-28 17:58:06 +08:00
ccp-dev-v5.c crypto: ccp - Fix XTS-AES-128 support on v5 CCPs 2017-08-04 09:27:41 +08:00
ccp-dev.c crypto: ccp - remove duplicate module version and author entry 2017-08-03 13:47:21 +08:00
ccp-dev.h crypto: ccp - Fix XTS-AES-128 support on v5 CCPs 2017-08-04 09:27:41 +08:00
ccp-dmaengine.c dmaengine updates for 4.14-rc1 2017-09-07 14:03:05 -07:00
ccp-ops.c crypto: ccp - use dma_mapping_error to check map error 2017-08-17 16:53:33 +08:00
sp-dev.c crypto: ccp - remove ccp_present() check from device initialize 2017-07-18 18:15:55 +08:00
sp-dev.h csrypto: ccp - Expand RSA support for a v5 ccp 2017-07-28 17:58:06 +08:00
sp-pci.c crypto: ccp - rename ccp driver initialize files as sp device 2017-07-18 18:15:54 +08:00
sp-platform.c crypto: ccp - rename ccp driver initialize files as sp device 2017-07-18 18:15:54 +08:00