From owner-svn-src-all@FreeBSD.ORG Thu Jul 25 15:54:46 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8DBC453B; Thu, 25 Jul 2013 15:54:46 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 4ECF820A9; Thu, 25 Jul 2013 15:54:46 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id EB033104208F; Fri, 26 Jul 2013 01:54:34 +1000 (EST) Date: Fri, 26 Jul 2013 01:54:33 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Marko Zec Subject: Re: svn commit: r253346 - in head/sys: kern net netgraph netgraph/bluetooth/socket In-Reply-To: <201307251048.33475.zec@fer.hr> Message-ID: <20130726015202.O2570@besplex.bde.org> References: <201307150132.r6F1WttU081255@svn.freebsd.org> <20130725080758.GE948@alchemy.franken.de> <201307251048.33475.zec@fer.hr> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=YYGEuWhf c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=O1joYcyITo4A:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=tFGGZ4DTOH8A:10 a=6I5d2MoRAAAA:8 a=3jECLxWCSvKPP1vQ-c4A:9 a=CjuIK1q_8ugA:10 Cc: Craig Rodrigues , svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Marius Strobl X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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 Jul 2013 15:54:46 -0000 On Thu, 25 Jul 2013, Marko Zec wrote: > On Thursday 25 July 2013 10:07:58 Marius Strobl wrote: >> On Mon, Jul 15, 2013 at 01:32:55AM +0000, Craig Rodrigues wrote: >>> Author: rodrigc >>> Date: Mon Jul 15 01:32:55 2013 >>> New Revision: 253346 >>> URL: http://svnweb.freebsd.org/changeset/base/253346 >>> >>> Log: >>> PR: 168520 170096 >>> Submitted by: adrian, zec >>> >>> Fix multiple kernel panics when VIMAGE is enabled in the kernel. >>> These fixes are based on patches submitted by Adrian Chadd and Marko >>> Zec. >>> >>> (1) Set curthread->td_vnet to vnet0 in device_probe_and_attach() >>> just before calling device_attach(). This fixes multiple VIMAGE >>> related kernel panics when trying to attach Bluetooth or USB Ethernet >>> devices because curthread->td_vnet is NULL. >>> >>> (2) Set curthread->td_vnet in if_detach(). This fixes kernel panics >>> when detaching networking interfaces, especially USB Ethernet devices. >>> >>> (3) Use VNET_DOMAIN_SET() in ng_btsocket.c >>> >>> (4) In ng_unref_node() set curthread->td_vnet. This fixes kernel >>> panics when detaching Netgraph nodes. >>> >>> Modified: >>> head/sys/kern/subr_bus.c >>> head/sys/net/if.c >>> head/sys/netgraph/bluetooth/socket/ng_btsocket.c >>> head/sys/netgraph/ng_base.c >>> >>> Modified: head/sys/kern/subr_bus.c >>> ======================================================================= >>> ======= --- head/sys/kern/subr_bus.c Mon Jul 15 00:49:10 2013 (r253345) >>> +++ head/sys/kern/subr_bus.c Mon Jul 15 01:32:55 2013 (r253346) @@ >>> -53,6 +53,8 @@ __FBSDID("$FreeBSD$"); >>> #include >>> #include >>> >>> +#include >>> + >>> #include >>> >>> #include >>> @@ -2735,7 +2737,11 @@ device_probe_and_attach(device_t dev) >>> return (0); >>> else if (error != 0) >>> return (error); >>> - return (device_attach(dev)); >>> + >>> + CURVNET_SET_QUIET(vnet0); >>> + error = device_attach(dev); >>> + CURVNET_RESTORE(); >>> + return error; >>> } >> >> Uhm - do we really need to have that layering violation in subr_bus.c? >> Wouldn't it be sufficient to set curthread->td_vnet to vnet0 in >> if_alloc(9) or if_attach(9) at least instead? > > That wouldn't solve the issues with attaching netgraph node(s) to the > arriving device, nor potentially other issues unrelated to if_alloc or > if_attach. This patch also has some style bugs (change from silly parentheses around the return value to none. 2 returns in unchanged code visible in the patch still use normal style). Bruce