From owner-freebsd-net@freebsd.org Tue Feb 25 06:13:13 2020 Return-Path: Delivered-To: freebsd-net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E92E6251C98 for ; Tue, 25 Feb 2020 06:13:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 48RTBd5kShz41H5 for ; Tue, 25 Feb 2020 06:13:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id C3CAB251C97; Tue, 25 Feb 2020 06:13:13 +0000 (UTC) Delivered-To: net@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C3734251C96 for ; Tue, 25 Feb 2020 06:13:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48RTBd4p87z41Gj for ; Tue, 25 Feb 2020 06:13:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B27E9FB2 for ; Tue, 25 Feb 2020 06:13:13 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 01P6DDu3028594 for ; Tue, 25 Feb 2020 06:13:13 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 01P6DDYR028586 for net@FreeBSD.org; Tue, 25 Feb 2020 06:13:13 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 244247] Kernel panic due to racecondition in ng_eiface shutdown Date: Tue, 25 Feb 2020 06:13:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 12.1-STABLE X-Bugzilla-Keywords: crash X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: aleksandr.fedorov@itglobal.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Feb 2020 06:13:14 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D244247 Aleksandr Fedorov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aleksandr.fedorov@itglobal. | |com --- Comment #10 from Aleksandr Fedorov --- It seems that there are a race in the function ng_eiface_rmnode(). 613 static int 614 ng_eiface_rmnode(node_p node) 615 { 616 const priv_p priv =3D NG_NODE_PRIVATE(node); 617 struct ifnet *const ifp =3D priv->ifp; 618=20=20=20=20=20 619 /* 620 * the ifnet may be in a different vnet than the netgraph n= ode,=20 621 * hence we have to change the current vnet context here. 622 */ 623 CURVNET_SET_QUIET(ifp->if_vnet); 624 ifmedia_removeall(&priv->media); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove media 625 ether_ifdetach(ifp); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Detach interface. Remove interface from ifnet's list which protected by WLOCK(). 626 if_free(ifp); 627 CURVNET_RESTORE(); 628 free_unr(V_ng_eiface_unit, priv->unit); 629 free(priv, M_NETGRAPH); 630 NG_NODE_SET_PRIVATE(node, NULL); 631 NG_NODE_UNREF(node); 632 return (0); 633 } So, the media is already removed, but the interface is still available. I think the order should be different, like other interfaces do: 1) Detach interface. 2) Free used resources. Can you test the next patch: Index: sys/netgraph/ng_eiface.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- sys/netgraph/ng_eiface.c (revision 358308) +++ sys/netgraph/ng_eiface.c (working copy) @@ -621,9 +621,9 @@ * hence we have to change the current vnet context here. */ CURVNET_SET_QUIET(ifp->if_vnet); - ifmedia_removeall(&priv->media); ether_ifdetach(ifp); if_free(ifp); + ifmedia_removeall(&priv->media); CURVNET_RESTORE(); free_unr(V_ng_eiface_unit, priv->unit); free(priv, M_NETGRAPH); --=20 You are receiving this mail because: You are the assignee for the bug.=