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

[Xen-changelog] [xen stable-4.1] libxl: suppress device assignment to HVM guest when there is no IOMMU



commit 52f527f726b756f6e42db3f7f05f5603c4f69dfd
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jul 9 10:07:06 2013 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jul 9 10:07:06 2013 +0200

    libxl: suppress device assignment to HVM guest when there is no IOMMU
    
    This in effect copies similar logic from xend: While there's no way to
    check whether a device is assigned to a particular guest,
    XEN_DOMCTL_test_assign_device at least allows checking whether an
    IOMMU is there and whether a device has been assign to _some_
    guest.
    
    For the time being, this should be enough to cover for the missing
    error checking/recovery in other parts of libxl's device assignment
    paths.
    
    There remains a (functionality-, but not security-related) race in
    that the iommu should be set up earlier, but this is too risky a
    change for this stage of the 4.3 release.
    
    This is a security issue, XSA-61.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Tested-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
    Acked-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    master commit: 826eb17271d3c647516d9944c47b0779afedea25
    master date: 2013-07-01 15:20:28 +0100
    master commit: 826eb17271d3c647516d9944c47b0779afedea25
    master date: 2013-07-01 15:20:28 +0100
---
 tools/libxl/libxl_pci.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 9c76bce..61bef12 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -786,6 +786,18 @@ int libxl__device_pci_add(libxl_ctx *ctx, uint32_t domid, 
libxl_device_pci *pcid
     int num_assigned, i, rc;
     int stubdomid = 0;
 
+    if (libxl__domain_is_hvm(ctx, domid)) {
+        rc = xc_test_assign_device(ctx->xch, domid, pcidev_value(pcidev));
+        if (rc) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                       "PCI device %04x:%02x:%02x.%u %s?",
+                       pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func,
+                       errno == ENOSYS ? "cannot be assigned - no IOMMU"
+                                       : "already assigned to a different 
guest");
+            goto out;
+        }
+    }
+
     if (!libxl_pcidev_assignable(ctx, pcidev)) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device %x:%x:%x.%x is not 
assignable",
                    pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.1

_______________________________________________
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®.