crypto: ccp/gcm - use const time tag comparison.
authorCfir Cohen <cfir@google.com>
Tue, 2 Jul 2019 17:32:56 +0000 (10:32 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 Jul 2019 05:39:54 +0000 (13:39 +0800)
Avoid leaking GCM tag through timing side channel.

Fixes: 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
Cc: <stable@vger.kernel.org> # v4.12+
Signed-off-by: Cfir Cohen <cfir@google.com>
Acked-by: Gary R Hook <ghook@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-ops.c

index 9ecc1bb..3ebe031 100644 (file)
@@ -850,7 +850,8 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
                if (ret)
                        goto e_tag;
 
-               ret = memcmp(tag.address, final_wa.address, AES_BLOCK_SIZE);
+               ret = crypto_memneq(tag.address, final_wa.address,
+                                   AES_BLOCK_SIZE) ? -EBADMSG : 0;
                ccp_dm_free(&tag);
        }