From: Tim Deegan Subject: Re: Is this a racing bug in page_make_sharable()? Date: Thu, 10 Jan 2013 17:25:35 +0000 Message-ID: <20130110172535.GI99373@ocelot.phlegethon.org> References: <4F14345B.4040807@gmail.com> <20120117105323.GA74654@ocelot.phlegethon.org> <50DC6ABF.7020003@gmail.com> <20130110130058.GD99373@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andres Lagar-Cavilla Cc: Lixiuchang , Xiaowei Yang , Nai Xia , "Luohao (brian)" , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org At 11:36 -0500 on 10 Jan (1357817806), Andres Lagar-Cavilla wrote: > Hi there, thanks for the report. Sorry I didn't respond earlier, fell through the cracks. > > Having said that... > On Jan 10, 2013, at 8:00 AM, Tim Deegan wrote: > > > Hi, > > > > At 23:35 +0800 on 27 Dec (1356651327), Nai Xia wrote: > >> I think I can construct a bug by interleaving the two code paths: > >> > >> in guest_remove_page() | in page_make_sharable() > >> ------------------------------------------------------------------------------------------------------------------------------ > >> if ( p2m_is_shared(p2mt) ) ..... > >> ... ..... > >> page = mfn_to_page(mfn); ..... > >> ..... > >> > >> if ( > >> !get_page_and_type(page, > >> d, PGT_shared_page) ) > >> // success > >> > >> ......... > >> if ( page->count_info != > >> (PGC_allocated | (2 + > >> expected_refcnt)) ) // > >> also pass > >> > >> > >> if ( unlikely(!get_page(page, d)) ) > >> > >> /* go on to remove page */ /* go on to add page to > >> cow domain */ > >> ------------------------------------------------------------------------------------------------------------------------------------- > >> > >> > >> is there anything that can already prevent such racing or is this really > >> can happen? > > > > I think this race can happen. > > Through a p2m entry in a domain. Is this the same domain as the one > for which quest_remove_page is executing? Then all is serialized > through the p2m lock, no race. Right, that's what I was missing. Because guest_remove_page has called get_gfn_query on the gfn, and not yet called put_gfn(), page_make_sharable() can't be running. All is well. :) Thanks, Tim.