netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey
@ 2024-07-06  6:50 Gaosheng Cui
  2024-07-08  9:10 ` Simon Horman
  2024-07-08 14:51 ` Chuck Lever
  0 siblings, 2 replies; 4+ messages in thread
From: Gaosheng Cui @ 2024-07-06  6:50 UTC (permalink / raw)
  To: trondmy, anna, chuck.lever, jlayton, neilb, kolga, Dai.Ngo, tom,
	davem, edumazet, kuba, pabeni, steved, kwc, cuigaosheng1
  Cc: linux-nfs, netdev

If we fail to call crypto_sync_skcipher_setkey, we should free the
memory allocation for cipher, replace err_return with err_free_cipher
to free the memory of cipher.

Fixes: 4891f2d008e4 ("gss_krb5: import functionality to derive keys into the kernel")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 net/sunrpc/auth_gss/gss_krb5_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/auth_gss/gss_krb5_keys.c b/net/sunrpc/auth_gss/gss_krb5_keys.c
index 06d8ee0db000..4eb19c3a54c7 100644
--- a/net/sunrpc/auth_gss/gss_krb5_keys.c
+++ b/net/sunrpc/auth_gss/gss_krb5_keys.c
@@ -168,7 +168,7 @@ static int krb5_DK(const struct gss_krb5_enctype *gk5e,
 		goto err_return;
 	blocksize = crypto_sync_skcipher_blocksize(cipher);
 	if (crypto_sync_skcipher_setkey(cipher, inkey->data, inkey->len))
-		goto err_return;
+		goto err_free_cipher;
 
 	ret = -ENOMEM;
 	inblockdata = kmalloc(blocksize, gfp_mask);
-- 
2.25.1


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

* Re: [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey
  2024-07-06  6:50 [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey Gaosheng Cui
@ 2024-07-08  9:10 ` Simon Horman
  2024-07-08 14:51 ` Chuck Lever
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-07-08  9:10 UTC (permalink / raw)
  To: Gaosheng Cui
  Cc: trondmy, anna, chuck.lever, jlayton, neilb, kolga, Dai.Ngo, tom,
	davem, edumazet, kuba, pabeni, steved, kwc, linux-nfs, netdev

On Sat, Jul 06, 2024 at 02:50:08PM +0800, Gaosheng Cui wrote:
> If we fail to call crypto_sync_skcipher_setkey, we should free the
> memory allocation for cipher, replace err_return with err_free_cipher
> to free the memory of cipher.
> 
> Fixes: 4891f2d008e4 ("gss_krb5: import functionality to derive keys into the kernel")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey
  2024-07-06  6:50 [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey Gaosheng Cui
  2024-07-08  9:10 ` Simon Horman
@ 2024-07-08 14:51 ` Chuck Lever
  2024-07-08 20:08   ` Anna Schumaker
  1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever @ 2024-07-08 14:51 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker
  Cc: cuigaosheng1, jlayton, neilb, kolga, Dai.Ngo, tom, davem,
	edumazet, kuba, pabeni, steved, kwc, linux-nfs, netdev

On Sat, Jul 06, 2024 at 02:50:08PM +0800, Gaosheng Cui wrote:
> If we fail to call crypto_sync_skcipher_setkey, we should free the
> memory allocation for cipher, replace err_return with err_free_cipher
> to free the memory of cipher.
> 
> Fixes: 4891f2d008e4 ("gss_krb5: import functionality to derive keys into the kernel")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>  net/sunrpc/auth_gss/gss_krb5_keys.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sunrpc/auth_gss/gss_krb5_keys.c b/net/sunrpc/auth_gss/gss_krb5_keys.c
> index 06d8ee0db000..4eb19c3a54c7 100644
> --- a/net/sunrpc/auth_gss/gss_krb5_keys.c
> +++ b/net/sunrpc/auth_gss/gss_krb5_keys.c
> @@ -168,7 +168,7 @@ static int krb5_DK(const struct gss_krb5_enctype *gk5e,
>  		goto err_return;
>  	blocksize = crypto_sync_skcipher_blocksize(cipher);
>  	if (crypto_sync_skcipher_setkey(cipher, inkey->data, inkey->len))
> -		goto err_return;
> +		goto err_free_cipher;
>  
>  	ret = -ENOMEM;
>  	inblockdata = kmalloc(blocksize, gfp_mask);
> -- 
> 2.25.1
> 

Anna, Trond, would you like me to take this through the NFSD tree?

-- 
Chuck Lever

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

* Re: [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey
  2024-07-08 14:51 ` Chuck Lever
@ 2024-07-08 20:08   ` Anna Schumaker
  0 siblings, 0 replies; 4+ messages in thread
From: Anna Schumaker @ 2024-07-08 20:08 UTC (permalink / raw)
  To: Chuck Lever
  Cc: Trond Myklebust, cuigaosheng1, jlayton, neilb, kolga, Dai.Ngo,
	tom, davem, edumazet, kuba, pabeni, steved, kwc, linux-nfs,
	netdev

On Mon, Jul 8, 2024 at 10:52 AM Chuck Lever <chuck.lever@oracle.com> wrote:
>
> On Sat, Jul 06, 2024 at 02:50:08PM +0800, Gaosheng Cui wrote:
> > If we fail to call crypto_sync_skcipher_setkey, we should free the
> > memory allocation for cipher, replace err_return with err_free_cipher
> > to free the memory of cipher.
> >
> > Fixes: 4891f2d008e4 ("gss_krb5: import functionality to derive keys into the kernel")
> > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> > ---
> >  net/sunrpc/auth_gss/gss_krb5_keys.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/sunrpc/auth_gss/gss_krb5_keys.c b/net/sunrpc/auth_gss/gss_krb5_keys.c
> > index 06d8ee0db000..4eb19c3a54c7 100644
> > --- a/net/sunrpc/auth_gss/gss_krb5_keys.c
> > +++ b/net/sunrpc/auth_gss/gss_krb5_keys.c
> > @@ -168,7 +168,7 @@ static int krb5_DK(const struct gss_krb5_enctype *gk5e,
> >               goto err_return;
> >       blocksize = crypto_sync_skcipher_blocksize(cipher);
> >       if (crypto_sync_skcipher_setkey(cipher, inkey->data, inkey->len))
> > -             goto err_return;
> > +             goto err_free_cipher;
> >
> >       ret = -ENOMEM;
> >       inblockdata = kmalloc(blocksize, gfp_mask);
> > --
> > 2.25.1
> >
>
> Anna, Trond, would you like me to take this through the NFSD tree?

Sure! That sounds good to me.

Anna

>
> --
> Chuck Lever

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

end of thread, other threads:[~2024-07-08 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-06  6:50 [PATCH -next] gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey Gaosheng Cui
2024-07-08  9:10 ` Simon Horman
2024-07-08 14:51 ` Chuck Lever
2024-07-08 20:08   ` Anna Schumaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).