netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn
Subject: Re: [PATCH v2] xfrm: fix memory leak in xfrm_add_acquire()
Date: Tue, 11 Nov 2025 00:07:40 +0100	[thread overview]
Message-ID: <aRJwPMPsvMfxSj1u@krikkit> (raw)
In-Reply-To: <20251110064125.593311-1-zilin@seu.edu.cn>

note: the subject prefix should be [PATCH ipsec vX] for fixes to the
ipsec tree. (sorry, I forgot to mention that in v1)

2025-11-10, 06:41:25 +0000, Zilin Guan wrote:
> The xfrm_add_acquire() function constructs an xfrm policy by calling
> xfrm_policy_construct(). This allocates the policy structure and
> potentially associates a security context and a device policy with it.
> 
> However, at the end of the function, the policy object is freed using
> only kfree() . This skips the necessary cleanup for the security context
> and device policy, leading to a memory leak.
> 
> To fix this, invoke the proper cleanup functions xfrm_dev_policy_delete(),
> xfrm_dev_policy_free(), and security_xfrm_policy_free() before freeing the
> policy object. This approach mirrors the error handling path in
> xfrm_add_policy(), ensuring that all associated resources are correctly
> released.
> 
> Fixes: 980ebd25794f ("[IPSEC]: Sync series - acquire insert")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
> Changes in v2:
> - Use the correct cleanup functions as per xfrm_add_policy().
> ---
>  net/xfrm/xfrm_user.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>

-- 
Sabrina

  reply	other threads:[~2025-11-10 23:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10  6:41 [PATCH v2] xfrm: fix memory leak in xfrm_add_acquire() Zilin Guan
2025-11-10 23:07 ` Sabrina Dubroca [this message]
2025-11-14  9:14   ` Steffen Klassert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aRJwPMPsvMfxSj1u@krikkit \
    --to=sd@queasysnail.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horms@kernel.org \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.com \
    --cc=zilin@seu.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).