Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Apr 2018 16:48:11 +0000 (UTC)
From:      "Jonathan T. Looney" <jtl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r332114 - head/sys/netinet
Message-ID:  <201804061648.w36GmBkd046593@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804061648.w36GmBkd046593>