Subject: Re: [PATCH net] tcp: properly terminate timers for kernel sockets

From: Jakub Kicinski <[email-masked]>
Date: Mon, 25 Mar 2024 06:34:01 -0700

On Sat, 23 Mar 2024 05:45:26 +0100 Eric Dumazet wrote:
> > On Fri, 22 Mar 2024 13:57:32 +0000 Eric Dumazet wrote:  
> > > +     if (!sk->sk_net_refcnt)
> > > +             inet_csk_clear_xmit_timers_sync(sk);  
> >
> > The thought that we should clear or poison sk_net at this point
> > (whether sk->sk_net_refcnt or not) keeps coming back to me.
> > If we don't guarantee the pointer is valid - to make it easier
> > for syzbot to catch invalid accesses?  
> 
> I do not think we should do this here.
> 
> Note that KASAN has quarantine, and can catch invalid UAF accesses anyway.
> 
> We could clear the base socket in sk_prot_free() but this will not
> make KASAN better.

I was thinking mostly about the kernel sockets being "special",
and therefore less well exercised by syzbot. But sk_net will
remain valid until all user space for that netns exists, IIUC,
so I take it back, the clearing has a real chance of adding bugs.