Skip to contentSkip to conversation

crypto: ccp/gcm - use const time tag comparison.

PATCH In review Cfir Cohen 3 participants 3 messages Jul 2, 2019 – Jul 18, 2019

Subsystems (3)
lore
Share & tools
lore

Cfir Cohen

author
#0 lore raw

PATCH v2 1/1 crypto: ccp/gcm - use const time tag comparison.

Avoid leaking GCM tag through timing side channel.

Fixes 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
Cc <[email protected]> # v4.12+
---
 drivers/crypto/ccp/ccp-ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +2 -1
index db8de89d990f..633670220f6c 100644
@@ -840,7 +840,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);
 	}
 
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Cfir Cohen

Avoid leaking GCM tag through timing side channel.

Fixes 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
Cc <[email protected]> # v4.12+
Quoted 19 lines
---
  drivers/crypto/ccp/ccp-ops.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +2 -1
index db8de89d990f..633670220f6c 100644
@@ -840,7 +840,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);
  	}
 
maintainer
#2 lore raw
In reply to Cfir Cohen
Quoted 8 lines · Cfir Cohen

Avoid leaking GCM tag through timing side channel.

Fixes 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
Cc <[email protected]> # v4.12+
---
 drivers/crypto/ccp/ccp-ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt