gnttab: never create host mapping unless asked to
authorJan Beulich <jbeulich@suse.com>
Fri, 2 Jun 2017 14:21:27 +0000 (15:21 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 7 Sep 2017 18:17:58 +0000 (19:17 +0100)
We shouldn't create a host mapping unless asked to even in the case of
mapping a granted MMIO page. In particular the mapping wouldn't be torn
down when processing the matching unmap request.

This is part of XSA-224.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Gbp-Pq: Name gnttab-never-create-host-mapping-unless-

xen/common/grant_table.c

index 548550bf96cc5d20811010a43da57122be127f7c..28d5015d4f8b28ff636d71fc8ef8df189696661e 100644 (file)
@@ -911,10 +911,13 @@ __gnttab_map_grant_ref(
             goto undo_out;
         }
 
-        rc = create_grant_host_mapping(
-            op->host_addr, frame, op->flags, cache_flags);
-        if ( rc != GNTST_okay )
-            goto undo_out;
+        if ( op->flags & GNTMAP_host_map )
+        {
+            rc = create_grant_host_mapping(op->host_addr, frame, op->flags,
+                                           cache_flags);
+            if ( rc != GNTST_okay )
+                goto undo_out;
+        }
     }
     else if ( owner == rd || owner == dom_cow )
     {