From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= Subject: Re: race condition in xen-gntdev Date: Mon, 29 Jun 2015 16:50:10 +0200 Message-ID: <20150629145010.GT982@mail-itl> References: <20150430144744.GF919@mail-itl> <20150527234508.GA14838@mail-itl> <20150617194211.GB11083@mail-itl> <20150622174626.GH5408@l.oracle.com> <20150622181335.GJ11083@mail-itl> <20150622183713.GD9631@l.oracle.com> <55885E88.2040805@tycho.nsa.gov> <20150626012824.GD967@mail-itl> <20150629143926.GA24629@l.oracle.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2703500298052346228==" Return-path: In-Reply-To: <20150629143926.GA24629@l.oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: Boris Ostrovsky , Daniel De Graaf , David Vrabel , xen-devel List-Id: xen-devel@lists.xenproject.org --===============2703500298052346228== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="D6z0c4W1rkZNF4Vu" Content-Disposition: inline --D6z0c4W1rkZNF4Vu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 29, 2015 at 10:39:26AM -0400, Konrad Rzeszutek Wilk wrote: > On Fri, Jun 26, 2015 at 03:28:24AM +0200, Marek Marczykowski-G=C3=B3recki= wrote: > > On Mon, Jun 22, 2015 at 03:14:16PM -0400, Daniel De Graaf wrote: > > > The reason that gntdev_release didn't have a lock is because there ar= e not > > > supposed to be any references to the areas pointed to by priv->maps w= hen it > > > is called. However, since the MMU notifier has not yet been unregist= ered, > > > it is apparently possible to race here; the comment on mmu_notifier_u= nregister > > > seems to confirm this as a possibility (as do the backtraces). > > >=20 > > > I think adding the lock will be sufficient. > >=20 > > Ok, so here is the patch: >=20 > Awesome! >=20 > Since you are the one who has been seeing this particular fault - any cha= nce > you could give it some soak time? If I recall your emails correctly it ta= kes > about a week or so before you saw the crash? Sure. I've already installed patched kernel, will report back results later. >=20 > >=20 > > -----------8<------------ > >=20 > > From b876e14888bdafa112c3265e6420543fa74aa709 Mon Sep 17 00:00:00 2001 > > From: =3D?UTF-8?q?Marek=3D20Marczykowski-G=3DC3=3DB3recki?=3D > > > > Date: Fri, 26 Jun 2015 02:16:49 +0200 > > Subject: [PATCH] xen/grant: fix race condition in gntdev_release > >=20 > > While gntdev_release is called, MMU notifier is still registered and > > can traverse priv->maps list even if no pages are mapped (which is the > > case - gntdev_release is called after all). But gntdev_release will > > clear that list, so make sure that only one of those things happens at > > the same time. > >=20 > > Signed-off-by: Marek Marczykowski-G=C3=B3recki > > --- > > drivers/xen/gntdev.c | 2 ++ > > 1 file changed, 2 insertions(+) > >=20 > > diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c > > index 8927485..4bd23bb 100644 > > --- a/drivers/xen/gntdev.c > > +++ b/drivers/xen/gntdev.c > > @@ -568,12 +568,14 @@ static int gntdev_release(struct inode *inode, st= ruct file *flip) > > =20 > > pr_debug("priv %p\n", priv); > > =20 > > + mutex_lock(&priv->lock); > > while (!list_empty(&priv->maps)) { > > map =3D list_entry(priv->maps.next, struct grant_map, next); > > list_del(&map->next); > > gntdev_put_map(NULL /* already removed */, map); > > } > > WARN_ON(!list_empty(&priv->freeable_maps)); > > + mutex_unlock(&priv->lock); > > =20 > > if (use_ptemod) > > mmu_notifier_unregister(&priv->mn, priv->mm); > > --=20 > > 1.9.3 > >=20 > >=20 > > --=20 > > Best Regards, > > Marek Marczykowski-G=C3=B3recki > > Invisible Things Lab > > A: Because it messes up the order in which people normally read text. > > Q: Why is top-posting such a bad thing? >=20 >=20 --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --D6z0c4W1rkZNF4Vu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVkVsiAAoJENuP0xzK19cs8WgH/RpUR5iWtyZ3spHHhgManxK7 6Nix5x4CGZA8mNL6ZTVaaRH2KQspE/1XNQeu1CAJIpqzTeKjKmht5vvr4gGcIi/+ Oavqs0wTWh4Dll5XxxvjrS44w10hY2HU/P6VEQ0awc8YdrLzmBxti0r5ygbLEJva MdDC8n95zC9KJiRrJdmr1kS2rfcshXGQIBBYcytzqMA9fUitkJleSSWtOJjcOLLc E/PF3Ix+WqEZcM8GWwmDE0QnQZsDi6mWnvgc6f5ZIxFeMTyamaQwkIMMaCeQqOLp zN1UatVcuj4T7mimGjpF+jTUcbip9M8KvuNnulY5IYFMRukwRrLIMQZbRZ/LMTc= =DuRQ -----END PGP SIGNATURE----- --D6z0c4W1rkZNF4Vu-- --===============2703500298052346228== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============2703500298052346228==--