From owner-svn-src-head@freebsd.org Tue Oct 23 08:25:29 2018 Return-Path: Delivered-To: svn-src-head@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 CC2BC10709A2; Tue, 23 Oct 2018 08:25:29 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::609]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Yandex CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3E2217026C; Tue, 23 Oct 2018 08:25:29 +0000 (UTC) (envelope-from bu7cher@yandex.ru) Received: from mxback16o.mail.yandex.net (mxback16o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::67]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 9249178394A; Tue, 23 Oct 2018 11:25:25 +0300 (MSK) Received: from smtp4p.mail.yandex.net (smtp4p.mail.yandex.net [2a02:6b8:0:1402::15:6]) by mxback16o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ttUBVkvQn1-PPxaLwL1; Tue, 23 Oct 2018 11:25:25 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1540283125; bh=dHBZiWAoJ72gZNAUIDO0GeEtrRfg09HLjP6JXvhm7JE=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=GZ5UB/rCpPyP8v7u2vJlR3w03rnJqjQApJ6dLBNvpNmj2PDVivmv/02uh5nYr/1mb NgnXtCdbwqtu2zvv57CdbLHNvHjXXTTLrJFLZq0PnYatXWTYfLg2bAV50FxIb7JrEF BvMeOSPXwPeIyixpjZnEUvOGCu81gAwm42mLiudA= Received: by smtp4p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id DK01cvNy5r-PORqrxwC; Tue, 23 Oct 2018 11:25:24 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1540283124; bh=dHBZiWAoJ72gZNAUIDO0GeEtrRfg09HLjP6JXvhm7JE=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=fFqzBvcHkeoFKtAqDHScOPLd1/YQMVXkcUW2clMHlOe2kVJbBcq17OrSuJfg9FpJE nNbCcWSJOY3/pg+LobZvwkaV9Wtl08VKnmyg5G0ebJ51hbeB5Stm/0f7WJZNWU9aBp /xznrUmXVLIn6Bo+jREQVhaPdtE9oU2Qi9ZU3bNw= Authentication-Results: smtp4p.mail.yandex.net; dkim=pass header.i=@yandex.ru Subject: Re: svn commit: r339554 - head/sys/net To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201810211824.w9LIOLuu094155@repo.freebsd.org> <6FD6264C-06D6-40F4-8EED-B4B1AD950214@FreeBSD.org> <5375183F-6F8B-4457-9CCD-511E214B5B16@FreeBSD.org> From: "Andrey V. Elsukov" Openpgp: id=E6591E1B41DA1516F0C9BC0001C5EA0410C8A17A Autocrypt: addr=bu7cher@yandex.ru; prefer-encrypt=mutual; keydata= xsBNBEwBF1kBCADB9sXFhBEUy8qQ4X63Y8eBatYMHGEFWN9ypS5lI3RE6qQW2EYbxNk7qUC5 21YIIS1mMFVBEfvR7J9uc7yaYgFCEb6Sce1RSO4ULN2mRKGHP3/Sl0ijZEjWHV91hY1YTHEF ZW/0GYinDf56sYpDDehaBF5wkWIo1+QK5nmj3vl0DIDCMNd7QEiWpyLVwECgLX2eOAXByT8B bCqVhJGcG6iFP7/B9Ll6uX5gb8thM9LM+ibwErDBVDGiOgvfxqidab7fdkh893IBCXa82H9N CNwnEtcgzh+BSKK5BgvPohFMgRwjti37TSxwLu63QejRGb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PzvI9VxDhlr2juEVMZYAqPLEJe+SSxbwLoz BcFCNdDAyXcaAzXsx/E02YWm1hIWNRxanAe7Vlg7OL+gvLpdtrYCMg28PNqKNyrQ87LQ49O9 50IIZDOtNFeR0FGucjcLPdS9PiEqCoH7/waJxWp6ydJ+g4OYRBYNM0EmMgy1N85JJrV1mi5i Message-ID: Date: Tue, 23 Oct 2018 11:23:44 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <5375183F-6F8B-4457-9CCD-511E214B5B16@FreeBSD.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MPiglBC6YO0Si1x3RODbhNcqNJM6lUdNm" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2018 08:25:30 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MPiglBC6YO0Si1x3RODbhNcqNJM6lUdNm Content-Type: multipart/mixed; boundary="qOefYdRaF5EQOchxqqA03uUxSvtuFxlz0"; protected-headers="v1" From: "Andrey V. Elsukov" To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: Subject: Re: svn commit: r339554 - head/sys/net References: <201810211824.w9LIOLuu094155@repo.freebsd.org> <6FD6264C-06D6-40F4-8EED-B4B1AD950214@FreeBSD.org> <5375183F-6F8B-4457-9CCD-511E214B5B16@FreeBSD.org> In-Reply-To: <5375183F-6F8B-4457-9CCD-511E214B5B16@FreeBSD.org> --qOefYdRaF5EQOchxqqA03uUxSvtuFxlz0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 23.10.2018 07:17, Kristof Provost wrote: > I think I understand what=E2=80=99s happening here. >=20 > With this patch I see a different panic: >=20 > |diff --git a/sys/net/if_ipsec.c b/sys/net/if_ipsec.c index > 91b11a455b3..146cb59aaaa 100644 --- a/sys/net/if_ipsec.c +++ > b/sys/net/if_ipsec.c @@ -134,6 +134,9 @@ ipsec_srchash(const struct > sockaddr *sa) { uint32_t hval; + KASSERT(V_ipsec4_srchtbl, ("NULL")); += > KASSERT(V_ipsec6_srchtbl, ("NULL (v6)")); + switch (sa->sa_family) { > #ifdef INET case AF_INET: @@ -265,17 +274,22 @@ static void > vnet_ipsec_uninit(const void *unused __unused) { > if_clone_detach(V_ipsec_cloner); free(V_ipsec_idhtbl, M_IPSEC); #ifdef > INET if (IS_DEFAULT_VNET(curvnet)) > ip_encap_unregister_srcaddr(ipsec4_srctab); free(V_ipsec4_srchtbl, > M_IPSEC); + V_ipsec4_srchtbl =3D NULL; + #endif #ifdef INET6 if > (IS_DEFAULT_VNET(curvnet)) ip6_encap_unregister_srcaddr(ipsec6_srctab);= > free(V_ipsec6_srchtbl, M_IPSEC); + V_ipsec4_srchtbl =3D NULL; #endif } > VNET_SYSUNINIT(vnet_ipsec_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, > SI_ORDER_ANY, | >=20 > That trips the KASSERT() in ipsec_srchash(). Basically, the problem is > that the V_ipsec4_srchtbl table gets freed in vnet_ipsec_uninit(), and > later we get a srcaddr_change_event(), which tries to iterate the list > (in ipsec_srcaddr()). Obviously iterating a freed list doesn=E2=80=99t = go well > for us (hence the 0xdeadc0dedeadc0de softc). >=20 > That also explains why this happens during the pf tests, even though > they don=E2=80=99t actually use IPSec. >=20 > I=E2=80=99m not quite sure how to best fix this though. I suppose we co= uld set > V_ipsec4_srchtbl to NULL (well, copy the pointer first, set it to NULL > and then free it so we don=E2=80=99t add a race condition) and then che= ck for > NULL in ipsec_srcaddr(). > It feels like the srcaddr_change_event needs to be per-vnet, so we can > unregister before we free V_ipsec4_srchtbl. I think the better fix would be adding IPSEC_WAIT() to vnet_ipsec_uninit() before doing free(). I'll try your test scenario and try to fix it. Thanks! --=20 WBR, Andrey V. Elsukov --qOefYdRaF5EQOchxqqA03uUxSvtuFxlz0-- --MPiglBC6YO0Si1x3RODbhNcqNJM6lUdNm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQEzBAEBCAAdFiEE5lkeG0HaFRbwybwAAcXqBBDIoXoFAlvO2pAACgkQAcXqBBDI oXpVOwf/b75QSWSdpyBOaeSrLAZJRLU8wf5G2dcdPVl4ihrmwz9gQ7sW+PSle7R6 OHnAf2qAvAQj4fpnQUmfI5bNDYck0/BJ4ujz2cqFZGKfcLA0VwPHWt0jsWNPzhSZ DkGyjCQi6I6dwSOVLs3Ojsvz1YlvLHF5/JERUa2otWVII2IJ6m5ixEiaBLrHM9BE 0cbR1hvmlfGh3a6MoKJRM0hVtFLZSudB90cHVzoa9TjXV3Lbwve+0AjDjQPwf+Bz UFd+5SJs2RWib/JBvgSnfsXqtZQcSNzsiznTCtALViJ34nWCVi5tjCfm9dW3EBxV ZhjrJIW24qeQD0wOMd3tOLkpmJRj+w== =gSoz -----END PGP SIGNATURE----- --MPiglBC6YO0Si1x3RODbhNcqNJM6lUdNm--