linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] macsec: Fix memory leaks in macsec_decrypt()
@ 2019-11-22 22:02 Navid Emamdoost
  2019-11-22 22:26 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-11-22 22:02 UTC (permalink / raw)
  To: David S. Miller, Johannes Berg, Taehee Yoo, Andreas Steinmetz,
	Navid Emamdoost, Michal Kubecek, Florian Westphal,
	Thomas Gleixner, netdev, linux-kernel
  Cc: emamd001

In the implementation of macsec_decrypt(), there are two memory leaks
when crypto_aead_decrypt() fails. Release allocated req and skb before
return.

Fixes: c3b7d0bd7ac2 ("macsec: fix rx_sa refcounting with decrypt callback")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/net/macsec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index afd8b2a08245..34c6fb4eb9ef 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -986,6 +986,8 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
 	dev_hold(dev);
 	ret = crypto_aead_decrypt(req);
 	if (ret == -EINPROGRESS) {
+		aead_request_free(req);
+		kfree_skb(skb);
 		return ERR_PTR(ret);
 	} else if (ret != 0) {
 		/* decryption/authentication failed
-- 
2.17.1


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

* Re: [PATCH] macsec: Fix memory leaks in macsec_decrypt()
  2019-11-22 22:02 [PATCH] macsec: Fix memory leaks in macsec_decrypt() Navid Emamdoost
@ 2019-11-22 22:26 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2019-11-22 22:26 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: David S. Miller, Johannes Berg, Taehee Yoo, Andreas Steinmetz,
	Michal Kubecek, Florian Westphal, Thomas Gleixner, netdev,
	linux-kernel, emamd001

Navid Emamdoost <navid.emamdoost@gmail.com> wrote:
> In the implementation of macsec_decrypt(), there are two memory leaks
> when crypto_aead_decrypt() fails. Release allocated req and skb before
> return.
> 
> Fixes: c3b7d0bd7ac2 ("macsec: fix rx_sa refcounting with decrypt callback")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/net/macsec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index afd8b2a08245..34c6fb4eb9ef 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -986,6 +986,8 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
>  	dev_hold(dev);
>  	ret = crypto_aead_decrypt(req);
>  	if (ret == -EINPROGRESS) {
> +		aead_request_free(req);
> +		kfree_skb(skb);

-EINPROGRESS means decryption is handled asynchronously, no?

>  		return ERR_PTR(ret);
>  	} else if (ret != 0) {
>  		/* decryption/authentication failed

This is the error handling/failure path.

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

end of thread, other threads:[~2019-11-22 22:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 22:02 [PATCH] macsec: Fix memory leaks in macsec_decrypt() Navid Emamdoost
2019-11-22 22:26 ` Florian Westphal

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).