crypto: nx - Fix memcpy() over-reading in nonce
authorKees Cook <keescook@chromium.org>
Wed, 16 Jun 2021 20:34:59 +0000 (13:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:55:39 +0000 (16:55 +0200)
commit 74c66120fda6596ad57f41e1607b3a5d51ca143d upstream.

Fix typo in memcpy() where size should be CTR_RFC3686_NONCE_SIZE.

Fixes: 030f4e968741 ("crypto: nx - Fix reentrancy bugs")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/nx/nx-aes-ctr.c

index 6d5ce1a66f1eeb12a949652c14dd38cfe9c904c1..02ad26012c665b684bdd89174e3cc0e8b3a83df6 100644 (file)
@@ -118,7 +118,7 @@ static int ctr3686_aes_nx_crypt(struct skcipher_request *req)
        struct nx_crypto_ctx *nx_ctx = crypto_skcipher_ctx(tfm);
        u8 iv[16];
 
-       memcpy(iv, nx_ctx->priv.ctr.nonce, CTR_RFC3686_IV_SIZE);
+       memcpy(iv, nx_ctx->priv.ctr.nonce, CTR_RFC3686_NONCE_SIZE);
        memcpy(iv + CTR_RFC3686_NONCE_SIZE, req->iv, CTR_RFC3686_IV_SIZE);
        iv[12] = iv[13] = iv[14] = 0;
        iv[15] = 1;