lkml.org 
[lkml]   [2019]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.2 65/85] crypto: talitos - check data blocksize in ablkcipher.
    Date
    From: Christophe Leroy <christophe.leroy@c-s.fr>

    commit ee483d32ee1a1a7f7d7e918fbc350c790a5af64a 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: Christophe Leroy <christophe.leroy@c-s.fr>
    Fixes: 4de9d0b547b9 ("crypto: talitos - Add ablkcipher algorithms")
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/crypto/talitos.c | 16 ++++++++++++++++
    1 file changed, 16 insertions(+)

    --- a/drivers/crypto/talitos.c
    +++ b/drivers/crypto/talitos.c
    @@ -1725,6 +1725,14 @@ static int ablkcipher_encrypt(struct abl
    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);
    @@ -1742,6 +1750,14 @@ static int ablkcipher_decrypt(struct abl
    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);

    \
     
     \ /
      Last update: 2019-09-18 08:29    [W:4.121 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site