Commit 02a49f07 authored by Christophe Leroy's avatar Christophe Leroy Committed by Kleber Sacilotto de Souza

crypto: talitos - check data blocksize in ablkcipher.

BugLink: https://bugs.launchpad.net/bugs/1845405

commit ee483d32 upstream.

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: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Fixes: 4de9d0b5 ("crypto: talitos - Add ablkcipher algorithms")
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent ca6abf79
......@@ -1641,6 +1641,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);
......@@ -1658,6 +1666,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment