]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86: replace bad ASSERT() in xenmem_add_to_physmap_one()
authorJan Beulich <jbeulich@suse.com>
Tue, 28 Nov 2017 12:14:10 +0000 (13:14 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 28 Nov 2017 12:14:10 +0000 (13:14 +0100)
There are no locks being held, i.e. it is possible to be triggered by
racy hypercall invocations. Subsequent code doesn't really depend on the
checked values, so this is not a security issue.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Release-acked-by: Julien Grall <julien.grall@linaro.org>
xen/arch/x86/mm.c

index 886a5ee327df8d378f64b3e6789de3443690b078..86c822d5771a45ecafcf6ad7fe16fe7bac6bfdad 100644 (file)
@@ -4143,8 +4143,12 @@ int xenmem_add_to_physmap_one(
     /* Unmap from old location, if any. */
     old_gpfn = get_gpfn_from_mfn(mfn_x(mfn));
     ASSERT( old_gpfn != SHARED_M2P_ENTRY );
-    if ( space == XENMAPSPACE_gmfn || space == XENMAPSPACE_gmfn_range )
-        ASSERT( old_gpfn == gfn );
+    if ( (space == XENMAPSPACE_gmfn || space == XENMAPSPACE_gmfn_range) &&
+         old_gpfn != gfn )
+    {
+        rc = -EXDEV;
+        goto put_both;
+    }
     if ( old_gpfn != INVALID_M2P_ENTRY )
         rc = guest_physmap_remove_page(d, _gfn(old_gpfn), mfn, PAGE_ORDER_4K);