Re: git: 453aa7fac989 - main - tcp: ensure the tcpcb is not NULL when logging an event

From: <tuexen_at_freebsd.org>
Date: Thu, 23 Feb 2023 10:32:05 UTC
> On 23. Feb 2023, at 03:59, Gleb Smirnoff <glebius@FreeBSD.org> wrote:
> 
> On Thu, Feb 23, 2023 at 01:04:35AM +0000, Michael Tuexen wrote:
> M> The branch main has been updated by tuexen:
> M> 
> M> URL: https://cgit.FreeBSD.org/src/commit/?id=453aa7fac9894945282bcf6ef55c9ebaaa1d7e40
> M> 
> M> commit 453aa7fac9894945282bcf6ef55c9ebaaa1d7e40
> M> Author:     Michael Tuexen <tuexen@FreeBSD.org>
> M> AuthorDate: 2023-02-23 01:01:53 +0000
> M> Commit:     Michael Tuexen <tuexen@FreeBSD.org>
> M> CommitDate: 2023-02-23 01:04:17 +0000
> M> 
> M>     tcp: ensure the tcpcb is not NULL when logging an event
> M>     
> M>     When calling tcp_bblog_pru() on some error paths, tp is NULL,
> M>     therefore handle it.
> 
> I wonder when does that happen? IMHO better fix such calls than
> plug the problem here.
The way I observed this was hitting
https://cgit.freebsd.org/src/tree/sys/netinet/tcp_usrreq.c#n519
via
https://cgit.freebsd.org/src/tree/sys/netinet/tcp_usrreq.c#n557
or
https://cgit.freebsd.org/src/tree/sys/netinet/tcp_usrreq.c#n561

I wanted to fix the panic() before others are running into it.
So I added the check for tp == NULL as it was in
https://cgit.freebsd.org/src/tree/sys/netinet/tcp_usrreq.c?h=stable/13#n141

I can change the code such that we just avoid calling tcp_bblog_pru()
with tp == NULL, or ensure tp != NULL in all cases, which is what I
would prefer.

We can chat about this in the next transport call.

Best regards
Michael
> -- 
> Gleb Smirnoff