From owner-freebsd-pf@FreeBSD.ORG Wed Aug 24 17:38:27 2005 Return-Path: X-Original-To: freebsd-pf@freebsd.org Delivered-To: freebsd-pf@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 052A716A421; Wed, 24 Aug 2005 17:38:27 +0000 (GMT) (envelope-from dhartmei@insomnia.benzedrine.cx) Received: from insomnia.benzedrine.cx (insomnia.benzedrine.cx [62.65.145.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 18F7643D55; Wed, 24 Aug 2005 17:38:25 +0000 (GMT) (envelope-from dhartmei@insomnia.benzedrine.cx) Received: from insomnia.benzedrine.cx (dhartmei@localhost [127.0.0.1]) by insomnia.benzedrine.cx (8.13.4/8.12.11) with ESMTP id j7OHcP8h031369 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Wed, 24 Aug 2005 19:38:25 +0200 (MEST) Received: (from dhartmei@localhost) by insomnia.benzedrine.cx (8.13.4/8.12.10/Submit) id j7OHcPxR013210; Wed, 24 Aug 2005 19:38:25 +0200 (MEST) Date: Wed, 24 Aug 2005 19:38:24 +0200 From: Daniel Hartmeier To: Pawel Jakub Dawidek Message-ID: <20050824173824.GA25807@insomnia.benzedrine.cx> References: <20050824150914.GA1603@garage.freebsd.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050824150914.GA1603@garage.freebsd.pl> User-Agent: Mutt/1.5.6i Cc: freebsd-pf@freebsd.org Subject: Re: PF doesn't work with changed interfaces names. X-BeenThere: freebsd-pf@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Technical discussion and general questions about packet filter \(pf\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Aug 2005 17:38:27 -0000 On Wed, Aug 24, 2005 at 05:09:14PM +0200, Pawel Jakub Dawidek wrote: > When we change interface name with: > > # ifconfig fxp0 name net0 > > and we add a firewall rule, restart pf, remove the rule, restart pf, we got: > > Fatal trap 12: page fault while in kernel mode The rule might have created an interface-bound state entry on fxp0. I don't know off-hand how 'ifconfig name' interacts with pf_if.c pfi_*() functions, but if it destroys the kif object of fxp0 (and creates a new one for net0), there might be a problem in pf_if.c pfi_maybe_destroy() #ifdef __FreeBSD__ if ((p->pfik_flags & (PFI_IFLAG_ATTACHED | PFI_IFLAG_GROUP)) || ((p->pfik_rules > 0 || p->pfik_states > 0) && (p->pfik_flags & PFI_IFLAG_PLACEHOLDER) == 0)) #else if ((p->pfik_flags & (PFI_IFLAG_ATTACHED | PFI_IFLAG_GROUP)) || p->pfik_rules > 0 || p->pfik_states > 0) #endif return (0); The non-FreeBSD version strictly returns when the pfi_kif object still contains state entries, but the FreeBSD version might be free'ing the object when it still contains state entries. Those state entries point back to the pfi_kif object that contains them. If this happens, you might see exactly the crash you describe, i.e. pf_state_compare_*() then tries to access the no-longer-existing pfi_kif object to traverse state entries in there, accessing invalid memory. I have to study the use of PFI_IFLAG_PLACEHOLDER more, maybe Max has an idea what goes wrong there on interface name changes (ifconfig name)... As a short-term workaround, I think disabling pf and flusing the state table (pfctl -d; pfctl -Fs) before the ifconfig invokation would prevent the panic. Daniel