Re: [PATCH net] tcp: fix forever orphan socket caused by tcp_abort

From: Jason Xing
Date: Mon Aug 05 2024 - 03:46:56 EST


On Mon, Aug 5, 2024 at 2:43 PM Lorenzo Colitti <lorenzo@xxxxxxxxxx> wrote:
>
> On Thu, Aug 1, 2024 at 10:11 PM Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
> > > This patch removes the SOCK_DEAD check in tcp_abort, making it send
> > > reset to peer and close the socket accordingly. Preventing the
> > > timer-less orphan from happening.
> > > [...]
> >
> > This seems legit, but are you sure these two blamed commits added this bug ?
> >
> > Even before them, we should have called tcp_done() right away, instead
> > of waiting for a (possibly long) timer to complete the job.
> >
> > This might be important when killing millions of sockets on a busy server.
> >
> > CC Lorenzo
> >
> > Lorenzo, do you recall why your patch was testing the SOCK_DEAD flag ?
>
> I think I took it from the original tcp_nuke_addr implementation that
> Android used before SOCK_DESTROY and tcp_abort were written. The
> oldest reference I could find to that code is this commit that went
> into 2.6.39 (!), which already had that check.
>
> https://android.googlesource.com/kernel/common/+/06611218f86dc353d5dd0cb5acac32a0863a2ae5
>
> I expect the check was intended to prevent force-closing the same socket twice.
>

Yes, I guess so.