]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.31/crypto-ccree-don-t-copy-zero-size-ciphertext.patch
Linux 4.19.31
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / crypto-ccree-don-t-copy-zero-size-ciphertext.patch
CommitLineData
eedc2696
GKH
1From 2b5ac17463dcb2411fed506edcf259a89bb538ba Mon Sep 17 00:00:00 2001
2From: Gilad Ben-Yossef <gilad@benyossef.com>
3Date: Tue, 15 Jan 2019 15:43:17 +0200
4Subject: crypto: ccree - don't copy zero size ciphertext
5
6From: Gilad Ben-Yossef <gilad@benyossef.com>
7
8commit 2b5ac17463dcb2411fed506edcf259a89bb538ba upstream.
9
10For decryption in CBC mode we need to save the last ciphertext block
11for use as the next IV. However, we were trying to do this also with
12zero sized ciphertext resulting in a panic.
13
14Fix this by only doing the copy if the ciphertext length is at least
15of IV size.
16
17Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
18Cc: stable@vger.kernel.org
19Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 drivers/crypto/ccree/cc_cipher.c | 3 ++-
24 1 file changed, 2 insertions(+), 1 deletion(-)
25
26--- a/drivers/crypto/ccree/cc_cipher.c
27+++ b/drivers/crypto/ccree/cc_cipher.c
28@@ -783,7 +783,8 @@ static int cc_cipher_decrypt(struct skci
29
30 memset(req_ctx, 0, sizeof(*req_ctx));
31
32- if (ctx_p->cipher_mode == DRV_CIPHER_CBC) {
33+ if ((ctx_p->cipher_mode == DRV_CIPHER_CBC) &&
34+ (req->cryptlen >= ivsize)) {
35
36 /* Allocate and save the last IV sized bytes of the source,
37 * which will be lost in case of in-place decryption.