VT-d: protect against bogus information coming from BIOS
authorJan Beulich <jbeulich@suse.com>
Wed, 14 Aug 2013 09:18:24 +0000 (11:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 14 Aug 2013 09:18:24 +0000 (11:18 +0200)
Add checks similar to those done by Linux: The DRHD address must not
be all zeros or all ones (Linux only checks for zero), and capabilities
as well as extended capabilities must not be all ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Ben Guthro <benjamin.guthro@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Ben Guthro <benjamin.guthro@citrix.com>
Acked by: Yang Zhang <yang.z.zhang@intel.com>
Acked-by: Xiantao Zhang <xiantao.zhang@intel.com>
xen/drivers/passthrough/vtd/dmar.c
xen/drivers/passthrough/vtd/iommu.c

index c810dbc5319f74675574684d0ed4b49282edebfc..8e162ff165286ac839862b69e93162d6d0b16f59 100644 (file)
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_header *header)
     if ( (ret = acpi_dmar_check_length(header, sizeof(*drhd))) != 0 )
         return ret;
 
+    if ( !drhd->address || !(drhd->address + 1) )
+        return -ENODEV;
+
     dmaru = xzalloc(struct acpi_drhd_unit);
     if ( !dmaru )
         return -ENOMEM;
index ddf713b423a641716dc23a5f3c30003b631e06cf..fd3abcbcefed922e659bab6ffc83503ca0a27b80 100644 (file)
@@ -1160,6 +1160,9 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd)
         dprintk(VTDPREFIX,
                 "cap = %"PRIx64" ecap = %"PRIx64"\n", iommu->cap, iommu->ecap);
     }
+    if ( !(iommu->cap + 1) || !(iommu->ecap + 1) )
+        return -ENODEV;
+
     if ( cap_fault_reg_offset(iommu->cap) +
          cap_num_fault_regs(iommu->cap) * PRIMARY_FAULT_REG_LEN >= PAGE_SIZE ||
          ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )