From owner-svn-src-all@freebsd.org Thu Jan 25 00:13:18 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 13427ECEA12; Thu, 25 Jan 2018 00:13:18 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 97A177F0A9; Thu, 25 Jan 2018 00:13:17 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id w0P0DA1j076041 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Jan 2018 16:13:10 -0800 (PST) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id w0P0DA8I076040; Wed, 24 Jan 2018 16:13:10 -0800 (PST) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Wed, 24 Jan 2018 16:13:10 -0800 From: Gleb Smirnoff To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r328313 - head/sys/netpfil/pf Message-ID: <20180125001310.GJ8113@FreeBSD.org> References: <201801240429.w0O4THIl059440@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201801240429.w0O4THIl059440@repo.freebsd.org> User-Agent: Mutt/1.9.1 (2017-09-22) 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:13:18 -0000 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. -- Gleb Smirnoff