From: David Vrabel Subject: Re: [PATCH] xen: avoid race in p2m handling Date: Thu, 16 Oct 2014 16:50:24 +0100 Message-ID: <543FE940.60901@citrix.com> References: <1413439997-32344-1-git-send-email-jgross@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1413439997-32344-1-git-send-email-jgross@suse.com> Sender: linux-kernel-owner@vger.kernel.org To: Juergen Gross , linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com, konrad.wilk@oracle.com List-Id: xen-devel@lists.xenproject.org On 16/10/14 07:13, Juergen Gross wrote: > When a new p2m leaf is allocated this leaf is linked into the p2m tree > via cmpxchg. Unfortunately the compare value for checking the success > of the update is read after checking for the need of a new leaf. It is > possible that a new leaf has been linked into the tree concurrently > in between. This could lead to a leaked memory page and to the loss of > some p2m entries. > > Avoid the race by using the read compare value for checking the need > of a new p2m leaf. [...] > @@ -579,11 +580,10 @@ static bool alloc_p2m(unsigned long pfn) > } > } > > - if (p2m_top[topidx][mididx] == p2m_identity || > - p2m_top[topidx][mididx] == p2m_missing) { > + p2m_orig = p2m_top[topidx][mididx]; Do you need to use ACCESS_ONCE() here? David