All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails
@ 2019-09-13 23:48 Navid Emamdoost
  2019-09-16 13:22 ` Lendacky, Thomas
  0 siblings, 1 reply; 6+ messages in thread
From: Navid Emamdoost @ 2019-09-13 23:48 UTC (permalink / raw)
  Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Tom Lendacky,
	Gary Hook, Herbert Xu, David S. Miller, linux-crypto,
	linux-kernel

In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
hmac_buf should be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/crypto/ccp/ccp-ops.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
index 9bc3c62157d7..cff16f0cc15b 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -1782,6 +1782,7 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
 			       LSB_ITEM_SIZE);
 			break;
 		default:
+			kfree(hmac_buf);
 			ret = -EINVAL;
 			goto e_ctx;
 		}
-- 
2.17.1


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

* Re: [PATCH] crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails
  2019-09-13 23:48 [PATCH] crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails Navid Emamdoost
@ 2019-09-16 13:22 ` Lendacky, Thomas
  2019-09-19 13:29   ` Gary R Hook
  0 siblings, 1 reply; 6+ messages in thread
From: Lendacky, Thomas @ 2019-09-16 13:22 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: emamd001, smccaman, kjlu, Hook, Gary, Herbert Xu,
	David S. Miller, linux-crypto, linux-kernel

On 9/13/19 6:48 PM, Navid Emamdoost wrote:
> In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
> hmac_buf should be released.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/crypto/ccp/ccp-ops.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
> index 9bc3c62157d7..cff16f0cc15b 100644
> --- a/drivers/crypto/ccp/ccp-ops.c
> +++ b/drivers/crypto/ccp/ccp-ops.c
> @@ -1782,6 +1782,7 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
>  			       LSB_ITEM_SIZE);
>  			break;
>  		default:
> +			kfree(hmac_buf);

Well, theoretically we can never reach this section since the routine
would have never proceeded past the first switch statement at the
beginning of the function. But, if the code is ever modified and some of
the switch statements missed then it's possible...

>  			ret = -EINVAL;
>  			goto e_ctx;

I know it's not part of your change, but this looks like it should be
goto e_data instead of e_ctx, too.

Thanks,
Tom

>  		}
> 

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

* Re: [PATCH] crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails
  2019-09-16 13:22 ` Lendacky, Thomas
@ 2019-09-19 13:29   ` Gary R Hook
  2019-09-19 16:04     ` [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid Navid Emamdoost
  0 siblings, 1 reply; 6+ messages in thread
From: Gary R Hook @ 2019-09-19 13:29 UTC (permalink / raw)
  To: Lendacky, Thomas, Navid Emamdoost
  Cc: emamd001, smccaman, kjlu, Hook, Gary, Herbert Xu,
	David S. Miller, linux-crypto, linux-kernel

On 9/16/19 8:22 AM, Lendacky, Thomas wrote:
> On 9/13/19 6:48 PM, Navid Emamdoost wrote:
>> In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
>> hmac_buf should be released.
>>
>> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
>> ---
>>   drivers/crypto/ccp/ccp-ops.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
>> index 9bc3c62157d7..cff16f0cc15b 100644
>> --- a/drivers/crypto/ccp/ccp-ops.c
>> +++ b/drivers/crypto/ccp/ccp-ops.c
>> @@ -1782,6 +1782,7 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
>>   			       LSB_ITEM_SIZE);
>>   			break;
>>   		default:
>> +			kfree(hmac_buf);
> Well, theoretically we can never reach this section since the routine
> would have never proceeded past the first switch statement at the
> beginning of the function. But, if the code is ever modified and some of
> the switch statements missed then it's possible...
>
>>   			ret = -EINVAL;
>>   			goto e_ctx;
> I know it's not part of your change, but this looks like it should be
> goto e_data instead of e_ctx, too.
I agree with this. Please resubmit with the suggested change, and use a 
commit message along the the lines of

crypto: ccp - Release all allocated memory if sha type is invalid


Gary

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

* [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid
  2019-09-19 13:29   ` Gary R Hook
@ 2019-09-19 16:04     ` Navid Emamdoost
  2019-09-19 17:00       ` Gary R Hook
  2019-10-04 15:44       ` Herbert Xu
  0 siblings, 2 replies; 6+ messages in thread
From: Navid Emamdoost @ 2019-09-19 16:04 UTC (permalink / raw)
  To: ghook
  Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Tom Lendacky,
	Gary Hook, Herbert Xu, David S. Miller, linux-crypto,
	linux-kernel

Release all allocated memory if sha type is invalid:
In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
hmac_buf should be released.

v2: fix the goto.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.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 9bc3c62157d7..440df9208f8f 100644
--- a/drivers/crypto/ccp/ccp-ops.c
+++ b/drivers/crypto/ccp/ccp-ops.c
@@ -1782,8 +1782,9 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
 			       LSB_ITEM_SIZE);
 			break;
 		default:
+			kfree(hmac_buf);
 			ret = -EINVAL;
-			goto e_ctx;
+			goto e_data;
 		}
 
 		memset(&hmac_cmd, 0, sizeof(hmac_cmd));
-- 
2.17.1


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

* Re: [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid
  2019-09-19 16:04     ` [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid Navid Emamdoost
@ 2019-09-19 17:00       ` Gary R Hook
  2019-10-04 15:44       ` Herbert Xu
  1 sibling, 0 replies; 6+ messages in thread
From: Gary R Hook @ 2019-09-19 17:00 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: emamd001, smccaman, kjlu, Lendacky, Thomas, Hook, Gary,
	Herbert Xu, David S. Miller, linux-crypto, linux-kernel



On 9/19/19 11:04 AM, Navid Emamdoost wrote:
> Release all allocated memory if sha type is invalid:
> In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
> hmac_buf should be released.
>
> v2: fix the goto.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Acked-by: Gary R Hook <gary.hook@amd.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 9bc3c62157d7..440df9208f8f 100644
> --- a/drivers/crypto/ccp/ccp-ops.c
> +++ b/drivers/crypto/ccp/ccp-ops.c
> @@ -1782,8 +1782,9 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
>   			       LSB_ITEM_SIZE);
>   			break;
>   		default:
> +			kfree(hmac_buf);
>   			ret = -EINVAL;
> -			goto e_ctx;
> +			goto e_data;
>   		}
>   
>   		memset(&hmac_cmd, 0, sizeof(hmac_cmd));


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

* Re: [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid
  2019-09-19 16:04     ` [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid Navid Emamdoost
  2019-09-19 17:00       ` Gary R Hook
@ 2019-10-04 15:44       ` Herbert Xu
  1 sibling, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2019-10-04 15:44 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: ghook, emamd001, smccaman, kjlu, Tom Lendacky, Gary Hook,
	David S. Miller, linux-crypto, linux-kernel

On Thu, Sep 19, 2019 at 11:04:48AM -0500, Navid Emamdoost wrote:
> Release all allocated memory if sha type is invalid:
> In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
> hmac_buf should be released.
> 
> v2: fix the goto.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/crypto/ccp/ccp-ops.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2019-10-04 15:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 23:48 [PATCH] crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails Navid Emamdoost
2019-09-16 13:22 ` Lendacky, Thomas
2019-09-19 13:29   ` Gary R Hook
2019-09-19 16:04     ` [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid Navid Emamdoost
2019-09-19 17:00       ` Gary R Hook
2019-10-04 15:44       ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.