summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorGilad Ben-Yossef <gilad@benyossef.com>2019-01-15 15:43:17 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-23 20:11:13 +0100
commitded8d6308ffd691475fe2c80e7ff4f3aa3979a99 (patch)
treeea86cf2ab66c2163c396a785efd35be6fa517850 /drivers/crypto
parent4fc9f0e1c9ffe9ae6dd8591055be95c5fc176996 (diff)
downloadblackbird-obmc-linux-ded8d6308ffd691475fe2c80e7ff4f3aa3979a99.tar.gz
blackbird-obmc-linux-ded8d6308ffd691475fe2c80e7ff4f3aa3979a99.zip
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>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/ccree/cc_cipher.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index e1fa2e8dbf2d..4ec93079daaf 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -801,7 +801,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.
OpenPOWER on IntegriCloud