public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp/gcm - use const time tag comparison.
@ 2019-07-02  0:01 Cfir Cohen
  2019-07-02  0:25 ` Eric Biggers
  0 siblings, 1 reply; 4+ messages in thread
From: Cfir Cohen @ 2019-07-02  0:01 UTC (permalink / raw)
  To: Tom Lendacky, Gary Hook, Herbert Xu, David Rientjes
  Cc: linux-kernel, linux-crypto, Cfir Cohen

Avoid leaking GCM tag through timing side channel.

Signed-off-by: Cfir Cohen <cfir@google.com>
---
 drivers/crypto/ccp/ccp-ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
index db8de89d990f..633670220f6c 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -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);
 	}
 
-- 
2.22.0.410.gd8fdbe21b5-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: ccp/gcm - use const time tag comparison.
  2019-07-02  0:01 [PATCH] crypto: ccp/gcm - use const time tag comparison Cfir Cohen
@ 2019-07-02  0:25 ` Eric Biggers
  2019-07-02 15:41   ` Gary R Hook
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2019-07-02  0:25 UTC (permalink / raw)
  To: Cfir Cohen
  Cc: Tom Lendacky, Gary Hook, Herbert Xu, David Rientjes, linux-kernel,
	linux-crypto

On Mon, Jul 01, 2019 at 05:01:32PM -0700, Cfir Cohen wrote:
> Avoid leaking GCM tag through timing side channel.
> 
> Signed-off-by: Cfir Cohen <cfir@google.com>
> ---
>  drivers/crypto/ccp/ccp-ops.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
> index db8de89d990f..633670220f6c 100644
> --- a/drivers/crypto/ccp/ccp-ops.c
> +++ b/drivers/crypto/ccp/ccp-ops.c
> @@ -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);
>  	}
>  
> -- 
> 2.22.0.410.gd8fdbe21b5-goog
> 

Looks like this needs:

	Fixes: 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
	Cc: <stable@vger.kernel.org> # v4.12+

- Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: ccp/gcm - use const time tag comparison.
  2019-07-02  0:25 ` Eric Biggers
@ 2019-07-02 15:41   ` Gary R Hook
  2019-07-02 15:53     ` Eric Biggers
  0 siblings, 1 reply; 4+ messages in thread
From: Gary R Hook @ 2019-07-02 15:41 UTC (permalink / raw)
  To: Eric Biggers, Cfir Cohen
  Cc: Lendacky, Thomas, Hook, Gary, Herbert Xu, David Rientjes,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org

On 7/1/19 7:25 PM, Eric Biggers wrote:
> On Mon, Jul 01, 2019 at 05:01:32PM -0700, Cfir Cohen wrote:
>> Avoid leaking GCM tag through timing side channel.
>>
>> Signed-off-by: Cfir Cohen <cfir@google.com>
>> ---
>>   drivers/crypto/ccp/ccp-ops.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
>> index db8de89d990f..633670220f6c 100644
>> --- a/drivers/crypto/ccp/ccp-ops.c
>> +++ b/drivers/crypto/ccp/ccp-ops.c
>> @@ -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);
>>   	}
>>   
>> -- 
>> 2.22.0.410.gd8fdbe21b5-goog
>>
> 
> Looks like this needs:
> 
> 	Fixes: 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
> 	Cc: <stable@vger.kernel.org> # v4.12+


Yes, it does. For clarity, does that mean you've taken care of this?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: ccp/gcm - use const time tag comparison.
  2019-07-02 15:41   ` Gary R Hook
@ 2019-07-02 15:53     ` Eric Biggers
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2019-07-02 15:53 UTC (permalink / raw)
  To: Gary R Hook
  Cc: Cfir Cohen, Lendacky, Thomas, Hook, Gary, Herbert Xu,
	David Rientjes, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org

On Tue, Jul 02, 2019 at 03:41:23PM +0000, Gary R Hook wrote:
> On 7/1/19 7:25 PM, Eric Biggers wrote:
> > On Mon, Jul 01, 2019 at 05:01:32PM -0700, Cfir Cohen wrote:
> >> Avoid leaking GCM tag through timing side channel.
> >>
> >> Signed-off-by: Cfir Cohen <cfir@google.com>
> >> ---
> >>   drivers/crypto/ccp/ccp-ops.c | 3 ++-
> >>   1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
> >> index db8de89d990f..633670220f6c 100644
> >> --- a/drivers/crypto/ccp/ccp-ops.c
> >> +++ b/drivers/crypto/ccp/ccp-ops.c
> >> @@ -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);
> >>   	}
> >>   
> >> -- 
> >> 2.22.0.410.gd8fdbe21b5-goog
> >>
> > 
> > Looks like this needs:
> > 
> > 	Fixes: 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
> > 	Cc: <stable@vger.kernel.org> # v4.12+
> 
> 
> Yes, it does. For clarity, does that mean you've taken care of this?
> 

Herbert is the person who will apply this, so he'd need to do it.  But it might
be better just to resend.

- Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-02 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-02  0:01 [PATCH] crypto: ccp/gcm - use const time tag comparison Cfir Cohen
2019-07-02  0:25 ` Eric Biggers
2019-07-02 15:41   ` Gary R Hook
2019-07-02 15:53     ` Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox