crypto: stm32/cryp - fix xts and race condition in crypto_engine requests
authorNicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Tue, 30 Nov 2021 07:54:56 +0000 (08:54 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 11 Dec 2021 05:48:05 +0000 (16:48 +1100)
Don't erase key:
If key is erased before the crypto_finalize_.*_request() call, some
pending process will run with a key={ 0 }.
Moreover if the key is reset at end of request, it breaks xts chaining
mode, as for last xts block (in case input len is not a multiple of
block) a new AES request is started without calling again set_key().

Fixes: 9e054ec21ef8 ("crypto: stm32 - Support for STM32 CRYP crypto module")
Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/stm32/stm32-cryp.c

index ab4a107a0860dae85e813160519b29d708c7009b..b2b553651964c6cf51f4f46692945970d4d3957a 100644 (file)
@@ -674,8 +674,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err)
        else
                crypto_finalize_skcipher_request(cryp->engine, cryp->req,
                                                   err);
-
-       memset(cryp->ctx->key, 0, cryp->ctx->keylen);
 }
 
 static int stm32_cryp_cpu_start(struct stm32_cryp *cryp)