[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aRby3noCsM-TKfkZ@secunet.com>
Date: Fri, 14 Nov 2025 10:14:06 +0100
From: Steffen Klassert <steffen.klassert@...unet.com>
To: Sabrina Dubroca <sd@...asysnail.net>
CC: Zilin Guan <zilin@....edu.cn>, <herbert@...dor.apana.org.au>,
<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <horms@...nel.org>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <jianhao.xu@....edu.cn>
Subject: Re: [PATCH v2] xfrm: fix memory leak in xfrm_add_acquire()
On Tue, Nov 11, 2025 at 12:07:40AM +0100, Sabrina Dubroca wrote:
> 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@....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@...asysnail.net>
Applied to the ipsec tree, thanks everyone!
Powered by blists - more mailing lists