From nobody Tue May 31 09:06:57 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 393521B5917A; Tue, 31 May 2022 09:07:06 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LC5y211j7z4mn2; Tue, 31 May 2022 09:07:06 +0000 (UTC) (envelope-from dim@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653988026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XDIukrJRGdW1OXFk5/xu4OiO6hppVwL0Pt8OgqBn6ks=; b=RufYCAYsURu1X2SeYvZ5oDysPgST7almev/ON2aKjn0AQbsxFtR1vk8WCqnnmVLzPFUDns qAWR8vtszO0lSaytmqkaeqj8xOe3IZqyuDbGZSbJihboYc4XWuq0IXBIpTQTpVP3YilJ8o lQLwQwJp2GC9VeAcnLlLgb+Mp+4byyJWepcujUFmzX7520iR97NUV2zzbv0YsiC3HSy2JJ i9OQDPZ5eu/oNAtC3tKtIxxXQhkpQ52ovtCtmDuGFdYwCjGR53XBCaXoasS3uel/FAtXDG YeuT+NYv2D/FyUOSpnhKhxLtE6nTtVKuxYsj800hy1gPhDi9RwBRjT3ie4pp7g== Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id DCA8A28C14; Tue, 31 May 2022 09:07:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (longrow.home.andric.com [192.168.0.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 5B7B06FFC; Tue, 31 May 2022 11:07:04 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_F9F1D825-98E6-482B-AFE0-F0F9BBB7E2D1"; protocol="application/pgp-signature"; micalg=pgp-sha1 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: git: 4dfd3ffc4488 - stable/13 - if: avoid interface destroy race From: Dimitry Andric In-Reply-To: <202205271637.24RGbHHW010235@gitrepo.freebsd.org> Date: Tue, 31 May 2022 11:06:57 +0200 Cc: Gleb Smirnoff , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-branches@freebsd.org" Message-Id: <1F175CE2-7649-4899-9CA0-8ADCE9206B6A@FreeBSD.org> References: <202205271637.24RGbHHW010235@gitrepo.freebsd.org> To: Kristof Provost X-Mailer: Apple Mail (2.3696.100.31) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653988026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XDIukrJRGdW1OXFk5/xu4OiO6hppVwL0Pt8OgqBn6ks=; b=Mnf0wu8iPGvBuH+fNGo6jQm/HMMJRe/FzWTD0ZHra/oNiZ3F3CA/ExnIVvcgP9iZCGnYSh mYO0G66uZ7qUDk17/WQH9KxW1MsjAj6nGiGvWZ7bTZO/AX6I57kizztK5XAha6gFOcFxRN wjVMw7k0rn4avzwYi1+9ij3fPWPPm3To59GH5ra9O+V4J/w8dRNzNy/ItO5LbmbNDH2ppe snDFEs4JaBbmWMO5lwRLn/uW44aoZkzOPHLkHYvNHD2f6FdcQ1IlGyPEN4pwkEY0w+6MV2 NbphM83iE+JuXLXd6M3KVfhqLLYzffzhpZsaNHXPb1oErSDJY1NJhF8kOuEY3Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653988026; a=rsa-sha256; cv=none; b=RkmFj5a3KKp6UJlEK/qC3+oHAmBaJ9P2Qwb5pEyt1+7lt5QZ3CmAPb89ubAbKhEioje0qL cfO57CvUnLkCxrRMpy/XiHJt+5E0a8bxEv3VKxeGzXlIubmutVtb+z5QzjSrn/DrqrkKEN 5M4NcCPdQqPqDQBWf9zErXh57otyDrkyM9AExYPCFTtYyFasdYsJzRPc2TsMxgMuS/OM06 DG5BvRunnMFdjFke+3u90S90EEdeRn6g7ffMb5u1c4uvk+9EUYHXHeMdlUNAXE28imRBlC BckGXSVkRx48uE49EOmLhrcY9aKdlmct0vyaIQNsBtElDllYcRv6sCXw3fdC9w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_F9F1D825-98E6-482B-AFE0-F0F9BBB7E2D1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 27 May 2022, at 18:37, Kristof Provost wrote: >=20 > The branch stable/13 has been updated by kp: >=20 > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D4dfd3ffc4488e5e2662cdc40deec17d8= 2432da0b >=20 > commit 4dfd3ffc4488e5e2662cdc40deec17d82432da0b > Author: Kristof Provost > AuthorDate: 2022-03-27 18:23:25 +0000 > Commit: Kristof Provost > CommitDate: 2022-05-27 16:25:10 +0000 >=20 > if: avoid interface destroy race >=20 > When we destroy an interface while the jail containing it is being > destroyed we risk seeing a race between if_vmove() and the = destruction > code, which results in us trying to move a destroyed interface. >=20 > Protect against this by using the ifnet_detach_sxlock to also = covert > if_vmove() (and not just detach). >=20 > PR: 262829 > MFC after: 3 weeks > Differential Revision: https://reviews.freebsd.org/D34704 >=20 > (cherry picked from commit = 868bf82153e8ff22f09a8860c872149e0fb6bdef) > --- > sys/net/if.c | 22 ++++++++++++++++++++-- > tests/sys/net/if_clone_test.sh | 29 +++++++++++++++++++++++++++++ > 2 files changed, 49 insertions(+), 2 deletions(-) >=20 > diff --git a/sys/net/if.c b/sys/net/if.c > index d4871ccbc1f7..091e9e64b99f 100644 > --- a/sys/net/if.c > +++ b/sys/net/if.c > @@ -548,7 +548,9 @@ vnet_if_return(const void *unused __unused) > IFNET_WUNLOCK(); >=20 > for (int j =3D 0; j < i; j++) { > + sx_xlock(&ifnet_detach_sxlock); > if_vmove(pending[j], pending[j]->if_home_vnet); > + sx_xunlock(&ifnet_detach_sxlock); > } >=20 > free(pending, M_IFNET); > @@ -1393,6 +1395,8 @@ if_vmove_loan(struct thread *td, struct ifnet = *ifp, char *ifname, int jid) > bool found; > bool shutdown; >=20 > + MPASS(ifindex_table[ifp->if_index].ife_ifnet =3D=3D ifp); > + > /* Try to find the prison within our visibility. */ > sx_slock(&allprison_lock); > pr =3D prison_find_child(td->td_ucred->cr_prison, jid); This particular part resulted in errors during one of my universe = builds: _.amd64.LINT: /home/dim/src/stable-13/sys/net/if.c:1398:8: error: use of undeclared = identifier 'ifindex_table' MPASS(ifindex_table[ifp->if_index].ife_ifnet =3D=3D ifp); ^ Note that it only seems to happen for the LINT kernels, though. It appears that ifindex_table changed from a VNET define into a global with Gleb's commit https://cgit.freebsd.org/src/commit/?id=3D80e60e236d85d= -Dimitry --Apple-Mail=_F9F1D825-98E6-482B-AFE0-F0F9BBB7E2D1 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYpXasQAKCRCwXqMKLiCW ozEuAKCEUzwSbJ3Tp+cVuPG7hzZINycUSQCgvSE2BYGvZYELOuQEcD6RQ+TGJhQ= =qo3m -----END PGP SIGNATURE----- --Apple-Mail=_F9F1D825-98E6-482B-AFE0-F0F9BBB7E2D1--