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

[Xen-changelog] [xen stable-4.3] amd/passthrough: Do not leak domain mappings from do_invalidate_dte()



commit 48825e566cfad72975d6579d31555ab806fb2f71
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Jan 10 11:06:05 2014 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Jan 10 11:06:05 2014 +0100

    amd/passthrough: Do not leak domain mappings from do_invalidate_dte()
    
    Coverity ID: 1135379
    
    As the code stands, the domain mapping will be leaked on each error path.
    
    The mapping can be for a much shorter period of time, and all the relevent
    information can be pulled out at once.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <JBeulich@xxxxxxxx>
    Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
    Tested-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
    master commit: 80dbe90a4e6b31f8cb859f7450fa3eed8695fd1d
    master date: 2013-12-10 16:16:49 +0100
---
 xen/drivers/passthrough/amd/iommu_guest.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_guest.c 
b/xen/drivers/passthrough/amd/iommu_guest.c
index 952600a..477de20 100644
--- a/xen/drivers/passthrough/amd/iommu_guest.c
+++ b/xen/drivers/passthrough/amd/iommu_guest.c
@@ -424,12 +424,17 @@ static int do_invalidate_dte(struct domain *d, 
cmd_entry_t *cmd)
                                         sizeof(dev_entry_t), gbdf);
     ASSERT(mfn_valid(dte_mfn));
 
+    /* Read guest dte information */
     dte_base = map_domain_page(dte_mfn);
 
     gdte = dte_base + gbdf % (PAGE_SIZE / sizeof(dev_entry_t));
 
     gdom_id  = get_domid_from_dte(gdte);
     gcr3_gfn = get_guest_cr3_from_dte(gdte);
+    glx      = get_glx_from_dte(gdte);
+    gv       = get_gv_from_dte(gdte);
+
+    unmap_domain_page(dte_base);
 
     /* Do not update host dte before gcr3 has been set */
     if ( gcr3_gfn == 0 )
@@ -440,7 +445,6 @@ static int do_invalidate_dte(struct domain *d, cmd_entry_t 
*cmd)
 
     ASSERT(mfn_valid(gcr3_mfn));
 
-    /* Read guest dte information */
     iommu = find_iommu_for_device(0, mbdf);
     if ( !iommu )
     {
@@ -449,11 +453,6 @@ static int do_invalidate_dte(struct domain *d, cmd_entry_t 
*cmd)
         return -ENODEV;
     }
 
-    glx = get_glx_from_dte(gdte);
-    gv = get_gv_from_dte(gdte);
-
-    unmap_domain_page(dte_base);
-
     /* Setup host device entry */
     hdom_id = host_domid(d, gdom_id);
     req_id = get_dma_requestor_id(iommu->seg, mbdf);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.3

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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