diff options
author | Gilad Ben-Yossef <gilad@benyossef.com> | 2019-01-15 16:43:17 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-23 22:09:40 +0300 |
commit | 6ed42ccca59db6c871f00c5746a769e5154324b6 (patch) | |
tree | 98671fd20a779a28ca79dd2e7f75af6b3c56db91 | |
parent | 0bdd345a384849d6d194dd84cd60b0ccc69fd8d1 (diff) | |
download | linux-6ed42ccca59db6c871f00c5746a769e5154324b6.tar.xz |
crypto: ccree - don't copy zero size ciphertext
commit 2b5ac17463dcb2411fed506edcf259a89bb538ba upstream.
For decryption in CBC mode we need to save the last ciphertext block
for use as the next IV. However, we were trying to do this also with
zero sized ciphertext resulting in a panic.
Fix this by only doing the copy if the ciphertext length is at least
of IV size.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/crypto/ccree/cc_cipher.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 7b9aa93544ba..54a39164aab8 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -783,7 +783,8 @@ static int cc_cipher_decrypt(struct skcipher_request *req) memset(req_ctx, 0, sizeof(*req_ctx)); - if (ctx_p->cipher_mode == DRV_CIPHER_CBC) { + if ((ctx_p->cipher_mode == DRV_CIPHER_CBC) && + (req->cryptlen >= ivsize)) { /* Allocate and save the last IV sized bytes of the source, * which will be lost in case of in-place decryption. |