From owner-cvs-src@FreeBSD.ORG Mon Jul 25 01:23:22 2005 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 92AF616A420; Mon, 25 Jul 2005 01:23:22 +0000 (GMT) (envelope-from csjp@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 53B8E43D48; Mon, 25 Jul 2005 01:23:22 +0000 (GMT) (envelope-from csjp@FreeBSD.org) Received: from freefall.freebsd.org (csjp@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j6P1NMIj016235; Mon, 25 Jul 2005 01:23:22 GMT (envelope-from csjp@freefall.freebsd.org) Received: (from csjp@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j6P1NMgX016234; Mon, 25 Jul 2005 01:23:22 GMT (envelope-from csjp) Date: Mon, 25 Jul 2005 01:23:22 +0000 From: "Christian S.J. Peron" To: Robert Watson Message-ID: <20050725012322.GB54033@freefall.freebsd.org> References: <200507241721.j6OHLImZ032073@repoman.freebsd.org> <20050725001935.B48825@fledge.watson.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050725001935.B48825@fledge.watson.org> User-Agent: Mutt/1.4.2.1i Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/net bpf.c bpfdesc.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2005 01:23:22 -0000 On Mon, Jul 25, 2005 at 12:24:44AM +0100, Robert Watson wrote: > > Looks like you hold bpf_mtx over calls to SYSCTL_OUT(), which may sleep if > it is required to write to a user memory page that is not in memory. > This can result in a lot of nasty things, including deadlock, odd lock > orders (especially if the page fault results in a signal being delivered > to a process), etc. In general, monitoring code of this sort needs to > store its output into a temporary kernel buffer and then copy that out, or > it needs to drop mutexes and accept race conditions. Generally the former > is easier to program, and the latter uses less kernel memory. > > Also, because the bpf_mtx isn't held between the first and second tests of > bpf_bpfd_cnt, a race can occur resulting in a panic when the kassert > fails, if the count is elevated before the call to hold the mutex, and not > once the mutex is released by the other thread. Does the kassert actually > add value here? In the unusual event of a race, you do a slightly more > expensive list walk, but only in rare cases. With the incorrect > KASSERT(), you panic instead. > > Robert N M Watson Robert, good catch, I will fix this up ASAP. -- Christian S.J. Peron csjp@FreeBSD.ORG FreeBSD Committer