Subject: Re: [RFC PATCH] ipv6: route: release reference of dsts cached in sockets

From: Jiri Wiesner <[email-masked]>
Date: Thu, 3 Oct 2024 19:01:26 +0200

On Wed, Oct 02, 2024 at 04:27:55PM -0400, Xin Long wrote:
> On Tue, Oct 1, 2024 at 11:26 AM Jiri Wiesner <[email-masked]> wrote:
> > I am afraid this patch is misguided. I would still like to find the source of the dst leak but I am also running out of time which the customer is willing to invest into investigating this issue.
> Is your kernel including this commit?
> 
> commit 28044fc1d4953b07acec0da4d2fc4784c57ea6fb
> Author: Joanne Koong <[email-masked]>
> Date:   Mon Aug 22 11:10:21 2022 -0700
> 
>     net: Add a bhash2 table hashed by port and address
> 
> After this commit, it seems in tcp_v6_connect(), the 'goto failure'
> may cause a dst leak.:
> 
>         dst = ip6_dst_lookup_flow(net, sk, &fl6, final_p);
>         ...
>         if (!saddr) {
>                 saddr = &fl6.saddr;
> 
>                 err = inet_bhash2_update_saddr(sk, saddr, AF_INET6);
>                 if (err)
>                         goto failure; <---
>         }
>         ...
>         ip6_dst_store(sk, dst, NULL, NULL);

Thanks for pointing this out. 28044fc1d495 seems to be an interesting commit as far as the number of Fixes is concerned. The commit was not backported to the 5.14-based SLES kernels, for which the unbalaced refcount bug was reported. The commit is part of the 6.4-based SLES kernels so I will have to see if all the patches with Fixes tags have been backported.
J.