linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gilad Ben-Yossef <gilad@benyossef.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: stable@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 7/7] crypto: ccree: don't copy zero size ciphertext
Date: Tue, 15 Jan 2019 15:43:17 +0200	[thread overview]
Message-ID: <20190115134318.28712-8-gilad@benyossef.com> (raw)
In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com>

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
---
 drivers/crypto/ccree/cc_cipher.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index 98ea53524250..e202d7c7ea00 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -800,7 +800,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.
-- 
2.20.1


  parent reply	other threads:[~2019-01-15 13:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 13:43 [PATCH 0/7] bug fixes and cleanups Gilad Ben-Yossef
2019-01-15 13:43 ` [PATCH 1/7] crypto: ccree: improve error handling Gilad Ben-Yossef
2019-01-15 13:43 ` [PATCH 2/7] crypto: ccree: add error message Gilad Ben-Yossef
2019-01-15 13:43 ` [PATCH 3/7] crypto: ccree: fix free of unallocated mlli buffer Gilad Ben-Yossef
2019-01-15 13:43 ` [PATCH 4/7] crypto: ccree: remove legacy leftover Gilad Ben-Yossef
2019-01-15 13:43 ` [PATCH 5/7] crypto: ccree: unmap buffer before copying IV Gilad Ben-Yossef
2019-01-15 13:43 ` [PATCH 6/7] crypto: ccree: shared irq lines are not a bug Gilad Ben-Yossef
2019-01-15 13:43 ` Gilad Ben-Yossef [this message]
2019-01-25 10:46 ` [PATCH 0/7] bug fixes and cleanups Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190115134318.28712-8-gilad@benyossef.com \
    --to=gilad@benyossef.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).