From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
horia.geanta@nxp.com
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v1 06/15] crypto: talitos - check data blocksize in ablkcipher.
Date: Tue, 21 May 2019 13:34:12 +0000 (UTC) [thread overview]
Message-ID: <a276c80d100ab95f14878c052d93a232a527b86d.1558445259.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <cover.1558445259.git.christophe.leroy@c-s.fr>
When data size is not a multiple of the alg's block size,
the SEC generates an error interrupt and dumps the registers.
And for NULL size, the SEC does just nothing and the interrupt
is awaited forever.
This patch ensures the data size is correct before submitting
the request to the SEC engine.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Fixes: 4de9d0b547b9 ("crypto: talitos - Add ablkcipher algorithms")
---
drivers/crypto/talitos.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 8b9a529f1b66..1e5410f92166 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -1756,6 +1756,14 @@ static int ablkcipher_encrypt(struct ablkcipher_request *areq)
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
struct talitos_edesc *edesc;
+ unsigned int blocksize =
+ crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(cipher));
+
+ if (!areq->nbytes)
+ return 0;
+
+ if (areq->nbytes % blocksize)
+ return -EINVAL;
/* allocate extended descriptor */
edesc = ablkcipher_edesc_alloc(areq, true);
@@ -1773,6 +1781,14 @@ static int ablkcipher_decrypt(struct ablkcipher_request *areq)
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher);
struct talitos_edesc *edesc;
+ unsigned int blocksize =
+ crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(cipher));
+
+ if (!areq->nbytes)
+ return 0;
+
+ if (areq->nbytes % blocksize)
+ return -EINVAL;
/* allocate extended descriptor */
edesc = ablkcipher_edesc_alloc(areq, false);
--
2.13.3
next prev parent reply other threads:[~2019-05-21 13:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-21 13:34 [PATCH v1 00/15] Fixing selftests failure on Talitos driver Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 01/15] crypto: talitos - fix skcipher failure due to wrong output IV Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 02/15] crypto: talitos - rename alternative AEAD algos Christophe Leroy
2019-05-21 17:54 ` Christophe Leroy
2019-05-21 18:10 ` Joe Perches
2019-05-21 13:34 ` [PATCH v1 03/15] crypto: talitos - reduce max key size for SEC1 Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 04/15] crypto: talitos - check AES key size Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 05/15] crypto: talitos - fix CTR alg blocksize Christophe Leroy
2019-05-21 13:34 ` Christophe Leroy [this message]
2019-05-21 13:34 ` [PATCH v1 07/15] crypto: talitos - fix ECB algs ivsize Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 08/15] crypto: talitos - Do not modify req->cryptlen on decryption Christophe Leroy
2019-05-28 8:20 ` Horia Geanta
2019-05-21 13:34 ` [PATCH v1 09/15] crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 10/15] crypto: talitos - properly handle split ICV Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 11/15] crypto: talitos - Align SEC1 accesses to 32 bits boundaries Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 12/15] crypto: talitos - fix AEAD processing Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 13/15] Revert "crypto: talitos - export the talitos_submit function" Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 14/15] crypto: talitos - use IS_ENABLED() in has_ftr_sec1() Christophe Leroy
2019-05-21 13:34 ` [PATCH v1 15/15] crypto: talitos - use SPDX-License-Identifier Christophe Leroy
2019-05-28 9:17 ` [PATCH v1 00/15] Fixing selftests failure on Talitos driver Horia Geanta
2019-05-28 16:48 ` Christophe Leroy
2019-05-30 13:42 ` 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=a276c80d100ab95f14878c052d93a232a527b86d.1558445259.git.christophe.leroy@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=horia.geanta@nxp.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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
all inboxes | Powered by JetHome®