]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
crypto: ccp - return an actual key size from RSA max_size callback
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Sat, 24 Feb 2018 16:03:21 +0000 (17:03 +0100)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Mon, 9 Apr 2018 13:42:00 +0000 (10:42 -0300)
commit89ee9d8ec9c2fc87e30d393a79708e7d27b3dedb
tree1b63ab2993ff61e71ef0a09ae44e9a66fa6f1e18
parent5dc2aef6d705668e243ab28499a426054c29029a
crypto: ccp - return an actual key size from RSA max_size callback

BugLink: http://bugs.launchpad.net/bugs/1762370
commit 0a9eb80e643064266868bd2fb2cd608e669309b0 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: ceeec0afd684 ("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>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/crypto/ccp/ccp-crypto-rsa.c