[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.13] xen/iommu: Check if the IOMMU was initialized before tearing down



commit c41fdabe8426079a0966b4e6bb9119c90bca62cb
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Fri Mar 5 15:46:27 2021 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Mar 5 15:46:27 2021 +0100

    xen/iommu: Check if the IOMMU was initialized before tearing down
    
    is_iommu_enabled() will return true even if the IOMMU has not been
    initialized (e.g. the ops are not set).
    
    In the case of an early failure in arch_domain_init(), the function
    iommu_destroy_domain() will be called even if the IOMMU is not
    initialized.
    
    This will result to dereference the ops which will be NULL and an host
    crash.
    
    Fix the issue by checking that ops has been set before accessing it.
    
    Fixes: 71e617a6b8f6 ("use is_iommu_enabled() where appropriate...")
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Paul Durrant <paul@xxxxxxx>
    master commit: d670ef3401b91d04c58d72cd8ce5579b4fa900d8
    master date: 2021-02-17 11:30:05 +0000
---
 xen/drivers/passthrough/iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index bab7a3d099..93d4377978 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -228,6 +228,13 @@ static void iommu_teardown(struct domain *d)
 {
     struct domain_iommu *hd = dom_iommu(d);
 
+    /*
+     * During early domain creation failure, we may reach here with the
+     * ops not yet initialized.
+     */
+    if ( !hd->platform_ops )
+        return;
+
     hd->platform_ops->teardown(d);
     tasklet_schedule(&iommu_pt_cleanup_tasklet);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.13



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.