[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <65a697a7-afb9-4f7d-a211-edfc18b19b9e@oracle.com>
Date: Thu, 6 Nov 2025 11:26:50 -0500
From: Chuck Lever <chuck.lever@...cle.com>
To: Zilin Guan <zilin@....edu.cn>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, horms@...nel.org,
kernel-tls-handshake@...ts.linux.dev, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, jianhao.xu@....edu.cn
Subject: Re: [PATCH] net/handshake: Fix memory leak in tls_handshake_accept()
On 11/6/25 9:45 AM, Zilin Guan wrote:
> In tls_handshake_accept(), a netlink message is allocated using
> genlmsg_new(). In the error handling path, genlmsg_cancel() is called
> to cancel the message construction, but the message itself is not freed.
> This leads to a memory leak.
>
> Fix this by calling nlmsg_free() in the error path after genlmsg_cancel()
> to release the allocated memory.
>
> Fixes: 2fd5532044a89 ("net/handshake: Add a kernel API for requesting a TLSv1.3 handshake")
> Signed-off-by: Zilin Guan <zilin@....edu.cn>
> ---
> net/handshake/tlshd.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/handshake/tlshd.c b/net/handshake/tlshd.c
> index 081093dfd553..8f9532a15f43 100644
> --- a/net/handshake/tlshd.c
> +++ b/net/handshake/tlshd.c
> @@ -259,6 +259,7 @@ static int tls_handshake_accept(struct handshake_req *req,
>
> out_cancel:
> genlmsg_cancel(msg, hdr);
> + nlmsg_free(msg);
> out:
> return ret;
> }
Reviewed-by: Chuck Lever <chuck.lever@...cle.com>
--
Chuck Lever
Powered by blists - more mailing lists