From owner-svn-src-all@freebsd.org Thu Jan 25 00:35:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0B6F3ECFA64 for ; Thu, 25 Jan 2018 00:35:08 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 808AA7FDD1 for ; Thu, 25 Jan 2018 00:35:07 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 927e8969-0167-11e8-91c6-33ffc249f3e8 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 927e8969-0167-11e8-91c6-33ffc249f3e8; Thu, 25 Jan 2018 00:34:59 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w0P0YwZ8009896; Wed, 24 Jan 2018 17:34:58 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1516840498.42536.213.camel@freebsd.org> Subject: Re: svn commit: r328313 - head/sys/netpfil/pf From: Ian Lepore To: Gleb Smirnoff , Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Wed, 24 Jan 2018 17:34:58 -0700 In-Reply-To: <20180125001310.GJ8113@FreeBSD.org> References: <201801240429.w0O4THIl059440@repo.freebsd.org> <20180125001310.GJ8113@FreeBSD.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2018 00:35:08 -0000 On Wed, 2018-01-24 at 16:13 -0800, Gleb Smirnoff wrote: >   Hi Kristof, > > On Wed, Jan 24, 2018 at 04:29:17AM +0000, Kristof Provost wrote: > K> Author: kp > K> Date: Wed Jan 24 04:29:16 2018 > K> New Revision: 328313 > K> URL: https://svnweb.freebsd.org/changeset/base/328313 > K>  > K> Log: > K>   pf: States have at least two references > K>    > K>   pf_unlink_state() releases a reference to the state without > checking if > K>   this is the last reference. It can't be, because > pf_state_insert() > K>   initialises it to two. KASSERT() that this is always the case. > K>    > K>   CID: 1347140 > K>  > K> Modified: > K>   head/sys/netpfil/pf/pf.c > K>  > K> Modified: head/sys/netpfil/pf/pf.c > K> > ===================================================================== > ========= > K> --- head/sys/netpfil/pf/pf.c Wed Jan 24 03:09:56 2018 > (r328312) > K> +++ head/sys/netpfil/pf/pf.c Wed Jan 24 04:29:16 2018 > (r328313) > K> @@ -1613,6 +1613,7 @@ int > K>  pf_unlink_state(struct pf_state *s, u_int flags) > K>  { > K>   struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(s)]; > K> + int last; > K>   > K>   if ((flags & PF_ENTER_LOCKED) == 0) > K>   PF_HASHROW_LOCK(ih); > K> @@ -1653,7 +1654,8 @@ pf_unlink_state(struct pf_state *s, u_int > flags) > K>   PF_HASHROW_UNLOCK(ih); > K>   > K>   pf_detach_state(s); > K> - refcount_release(&s->refs); > K> + last = refcount_release(&s->refs); > K> + KASSERT(last == 0, ("Incorrect state reference count")); > K>   > K>   return (pf_release_state(s)); > K>  } > > IMHO, we shouldn't emit extra code to please Coverity. We can mark it > as a false positive in the interface. It may make sense to add a > comment > for a human to explain why return isn't checked here. > Not to mention that when KASSERT compiles to nothing, what you're left with is a "defined but not used" warning for 'last'. -- Ian