From: Dan Magenheimer Subject: RE: xen crash in tmem: checking a xen pfn for domain ownership Date: Fri, 17 Sep 2010 09:48:38 -0700 (PDT) Message-ID: <425889fe-2961-445b-9581-55fba21bb89a@default> References: <5638cf67-e92c-45b3-8806-a0baba1eb8aa@default C8B95748.23679%keir.fraser@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , Jan Beulich Cc: Xen-devel List-Id: xen-devel@lists.xenproject.org Thanks for the reply, but I'm not sure I understand. Ignore memory sharing for now... Are you saying, yes, the ownership check IS performed? E.g. if gpfn is a random number, NULL will always be returned (unless of course the random number happens to be a valid gfn for current->domain)? Or are you saying its plausible that this IS the problem (that I am not checking for ownership)? Now bring memory sharing back in... Since tmem and memory sharing are supposed to be complementary (though I don't think anybody has ever tried using both together), are you saying I should change this one call from gfn_to_mfn() to gfn_to_mfn_unshare() for some reason (e.g. maybe to avoid a race)? Note that this code is just getting a virtual address to copy a page to/from the guest. Thanks, Dan > -----Original Message----- > From: Keir Fraser [mailto:keir.fraser@eu.citrix.com] > Sent: Friday, September 17, 2010 10:35 AM > To: Dan Magenheimer; Jan Beulich > Cc: Xen-devel > Subject: Re: xen crash in tmem: checking a xen pfn for domain ownership >=20 > If you could be doing memory sharing then you might need to use > gfn_to_mfn_unshare()? Otherwise it looks pretty plausible, and that one > flaw > is pretty minor as you're probably not using memshr. >=20 > -- Keir >=20 > On 17/09/2010 17:29, "Dan Magenheimer" > wrote: >=20 > > Does the construct: > > > > xen_pfn_t gpfn; > > p2m_type_t t; > > unsigned long mfn; > > > > mfn =3D mfn_x(gfn_to_mfn(current->domain, gpfn, &t)); > > if (t !=3D p2m_ram_rw || cli_mfn =3D=3D INVALID_MFN) > > return NULL; /* bad */ > > return map_domain_page(mfn) > > > > somehow check to ensure that pfn belongs to current->domain? > > (See cli_mfn_to_va() in common/tmem_xen.c.) > > > > If not, is there an easy way to perform that check? > > (preferably one that works for both HVM and PV guests) > > > > In debugging a tmem Linux-side guest patch, I discovered > > that a bad mfn passed by the guest can crash Xen and > > I think this assumption might be the problem. > > > > Thanks, > > Dan >=20 >=20