From: Kouya Shimura Subject: Re: [PATCH] x86 shadow: fix race when domain is dying Date: Fri, 27 Nov 2009 10:22:11 +0900 Message-ID: <7kskc0yd6j.fsf@pingu.sky.yk.fujitsu.co.jp> References: <7kvdgxya1h.fsf@pingu.sky.yk.fujitsu.co.jp> <20091126110746.GF14284@whitby.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20091126110746.GF14284@whitby.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Tim Deegan , Keir Fraser Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org Hi Tim, Thanks for correcting this. Indeed my patch is unsafe. Keir, This is serious. I think c/s 20508 should be applied to xen-3.4 too. Actually I met this for the first time in xen-3.4. Thanks, Kouya Tim Deegan writes: > Hi, > > At 08:17 +0000 on 26 Nov (1259223466), Kouya Shimura wrote: > > There are some cases that shadow_write_p2m_entry() is called after > > the domain is killed. It causes Xen to crash. > > Thanks for catching this! I'm afraid your fix opens a different race > window, though: any p2m operation that happens after d->is_dying is set > but before p2m_teardown() will corrupt the p2m (because the entry > wouldn't actually get written). If it also happens before > shadow_teardown() it could break the invariants of the shadow > pagetables, possibly causing a crash when shadow_teardown() is reached. > > The right fix is to test for whether shadow_teardown() has been called, > and if so, call safe_write_entry() without trying to fix up the shadows. > I've attached a patch. > > Cheers, > > Tim. > > -- > Tim Deegan > Principal Software Engineer, Citrix Systems (R&D) Ltd. > [Company #02300071, SL9 0DZ, UK.]