]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
x86/mm: don't retain page type reference when IOMMU operation fails
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Mar 2019 12:52:15 +0000 (13:52 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Mar 2019 12:52:15 +0000 (13:52 +0100)
The IOMMU update in _get_page_type() happens between recording of the
new reference and validation of the page for its new type (if
necessary). If the IOMMU operation fails, there's no point in actually
carrying out validation. Furthermore, with this resulting in failure
getting indicated to the caller, the recorded type reference also needs
to be dropped again.

Note that in case of failure of alloc_page_type() there's no need to
undo the IOMMU operation: Only special types get handed to the function.
The function, upon failure, clears ->u.inuse.type_info, effectively
converting the page to PGT_none. The IOMMU mapping, however, solely
depends on whether the type is PGT_writable_page.

This is XSA-291.

Reported-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm.c

index 90e082ed27b50809bb644b04b0a8dd00d8a64637..a63040a07109d8b3f9952b7713a27eb5a0bce5cc 100644 (file)
@@ -2953,6 +2953,13 @@ static int _get_page_type(struct page_info *page, unsigned long type,
                                              PAGE_ORDER_4K,
                                              IOMMUF_readable |
                                              IOMMUF_writable);
+
+            if ( unlikely(iommu_ret) )
+            {
+                _put_page_type(page, false, NULL);
+                rc = iommu_ret;
+                goto out;
+            }
         }
     }
 
@@ -2967,12 +2974,10 @@ static int _get_page_type(struct page_info *page, unsigned long type,
         rc = alloc_page_type(page, type, preemptible);
     }
 
+ out:
     if ( (x & PGT_partial) && !(nx & PGT_partial) )
         put_page(page);
 
-    if ( !rc )
-        rc = iommu_ret;
-
     return rc;
 }