]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: fix a reference counting error in MMU_MACHPHYS_UPDATE
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 20 Nov 2014 16:47:07 +0000 (17:47 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 20 Nov 2014 16:47:07 +0000 (17:47 +0100)
Any domain which can pass the XSM check against a translated guest can cause a
page reference to be leaked.

While shuffling the order of checks, drop the quite-pointless MEM_LOG().  This
brings the check in line with similar checks in the vicinity.

Discovered while reviewing the XSA-109/110 followup series.

This is XSA-113.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm.c

index 121aef4bbd069fa8c3c30910e1dbd1fb1c80a8a5..03808debf85e5e45540ec8c873a5fe8f8e6566a2 100644 (file)
@@ -3911,6 +3911,12 @@ long do_mmu_update(
 
         case MMU_MACHPHYS_UPDATE:
 
+            if ( unlikely(paging_mode_translate(pg_owner)) )
+            {
+                rc = -EINVAL;
+                break;
+            }
+
             mfn = req.ptr >> PAGE_SHIFT;
             gpfn = req.val;
 
@@ -3925,13 +3931,6 @@ long do_mmu_update(
                 break;
             }
 
-            if ( unlikely(paging_mode_translate(pg_owner)) )
-            {
-                MEM_LOG("Mach-phys update on auto-translate guest");
-                rc = -EINVAL;
-                break;
-            }
-
             set_gpfn_from_mfn(mfn, gpfn);
 
             paging_mark_dirty(pg_owner, mfn);