Author: jtl
Date: Fri Apr  6 16:48:11 2018
New Revision: 332114
URL: https://svnweb.freebsd.org/changeset/base/332114

Log:
  Check that in_pcbfree() is only called once for each PCB.  If that
  assumption is violated, "bad things" could follow.
  
  I believe such an assert would have detected some of the problems jch@
  was chasing in PR 203175 (see r307551).  We also use it in our internal
  TCP development efforts.  And, in case a bug does slip through to
  released code, this change silently ignores subsequent calls to
  in_pcbfree().
  
  Reviewed by:  rrs
  Sponsored by: Netflix, Inc.
  Differential Revision:        https://reviews.freebsd.org/D14990

Modified:
  head/sys/netinet/in_pcb.c

Modified: head/sys/netinet/in_pcb.c
==============================================================================
--- head/sys/netinet/in_pcb.c   Fri Apr  6 16:48:07 2018        (r332113)
+++ head/sys/netinet/in_pcb.c   Fri Apr  6 16:48:11 2018        (r332114)
@@ -1288,6 +1288,13 @@ in_pcbfree(struct inpcb *inp)
 
        KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__));
 
+       KASSERT((inp->inp_flags2 & INP_FREED) == 0,
+           ("%s: called twice for pcb %p", __func__, inp));
+       if (inp->inp_flags2 & INP_FREED) {
+               INP_WUNLOCK(inp);
+               return;
+       }
+
 #ifdef INVARIANTS
        if (pcbinfo == &V_tcbinfo) {
                INP_INFO_LOCK_ASSERT(pcbinfo);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to