From owner-freebsd-geom@FreeBSD.ORG Mon Jun 11 22:53:09 2012 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A20E9106566C for ; Mon, 11 Jun 2012 22:53:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 1B45A8FC08 for ; Mon, 11 Jun 2012 22:53:08 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5BMr49b076695; Tue, 12 Jun 2012 01:53:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q5BMr4O9052488; Tue, 12 Jun 2012 01:53:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5BMr4qB052487; Tue, 12 Jun 2012 01:53:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 12 Jun 2012 01:53:04 +0300 From: Konstantin Belousov To: Steven Haber Message-ID: <20120611225304.GK2337@deviant.kiev.zoral.com.ua> References: <56CE86D6660FF84498426FA7A33170B4033672EF@seaxch01.desktop.isilon.com> <20120611204334.GH2337@deviant.kiev.zoral.com.ua> <56CE86D6660FF84498426FA7A33170B403367535@seaxch01.desktop.isilon.com> <20120611215610.GJ2337@deviant.kiev.zoral.com.ua> <56CE86D6660FF84498426FA7A33170B403429115@seaxch01.desktop.isilon.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EMQjp+MvU6EBGjHc" Content-Disposition: inline In-Reply-To: <56CE86D6660FF84498426FA7A33170B403429115@seaxch01.desktop.isilon.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-geom@freebsd.org Subject: Re: Geom / destroy_dev() deadlock X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 22:53:09 -0000 --EMQjp+MvU6EBGjHc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 11, 2012 at 03:27:39PM -0700, Steven Haber wrote: > > I do not understand what you are proposing. Could you, please, show > > the patch ? >=20 > --- > src/sys/geom/geom_dev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/src/sys/geom/geom_dev.c b/src/sys/geom/geom_dev.c > index 38251e1..787235a 100644 > --- a/src/sys/geom/geom_dev.c > +++ b/src/sys/geom/geom_dev.c > @@ -497,7 +497,7 @@ g_dev_orphan(struct g_consumer *cp) > =20 > /* Destroy the struct cdev *so we get no more requests */ > unit =3D dev2unit(dev); > - destroy_dev(dev); > + destroy_dev_sched(dev); > free_unr(unithdr, unit); > =20 > /* Wait for the cows to come home */ Did you noted the comment above the block you changing ? The patch would cause races allowing arbitrary kernel memory corruption. The moment when the cdev is destroyed is somewhere in future, while structures that the cdev reference are freed synchronously. I tried to put some safety measures into destroy_dev_sched(9), namely CDP_SCHED_DTR flag that somewhat reduces the possibility of usermode accessing cdev after destroy_dev_sched(), but this cannot be eliminated entirely. --EMQjp+MvU6EBGjHc Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/WdtAACgkQC3+MBN1Mb4jpDQCgiBoVnAOan9YOILDSohRzV8HC uFIAn1QA/tyJRtL/xtZm7chlsJtltTcE =8EDz -----END PGP SIGNATURE----- --EMQjp+MvU6EBGjHc--