]> xenbits.xensource.com Git - xen.git/commitdiff
xen: only check for shared pages while any exist on teardown
authorIan Campbell <ian.campbell@citrix.com>
Thu, 9 Aug 2012 14:47:19 +0000 (15:47 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 9 Aug 2012 14:47:19 +0000 (15:47 +0100)
Avoids worst case behavour when guest has a large p2m.

This is XSA-11 / CVE-2012-3433

Signed-off-by: Tim Deegan <tim@xen.org>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen/arch/x86/mm/p2m.c

index 51ef7116caec0984d59cd54c8129e71c8597bda2..787b4be6a368290d7d99f2c69fe01a5ca0710f4c 100644 (file)
@@ -1725,6 +1725,8 @@ void p2m_teardown(struct domain *d)
 #ifdef __x86_64__
     for ( gfn=0; gfn < p2m->max_mapped_pfn; gfn++ )
     {
+        if ( atomic_read(&d->shr_pages) == 0 )
+            break;
         mfn = p2m->get_entry(d, gfn, &t, p2m_query);
         if ( mfn_valid(mfn) && (t == p2m_ram_shared) )
             BUG_ON(mem_sharing_unshare_page(d, gfn, MEM_SHARING_DESTROY_GFN));