Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Oct 2018 11:23:44 +0300
From:      "Andrey V. Elsukov" <bu7cher@yandex.ru>
To:        Kristof Provost <kp@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r339554 - head/sys/net
Message-ID:  <f8310b75-9421-8cc4-61d3-17b825cf7039@yandex.ru>
In-Reply-To: <5375183F-6F8B-4457-9CCD-511E214B5B16@FreeBSD.org>
References:  <201810211824.w9LIOLuu094155@repo.freebsd.org> <6FD6264C-06D6-40F4-8EED-B4B1AD950214@FreeBSD.org> <5375183F-6F8B-4457-9CCD-511E214B5B16@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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" <bu7cher@yandex.ru>
To: Kristof Provost <kp@FreeBSD.org>
Cc: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Message-ID: <f8310b75-9421-8cc4-61d3-17b825cf7039@yandex.ru>
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f8310b75-9421-8cc4-61d3-17b825cf7039>