diff options
author | Jan Beulich <jbeulich@suse.com> | 2013-08-20 15:00:13 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2013-08-20 15:00:13 +0200 |
commit | c2c3d78cb84f1b47757cb3f5c1495ba662fae3a3 (patch) | |
tree | 6a31ed3e73ceefcd9abb4a90a29721d79097e5cb | |
parent | 12e46b462595b53ff4bc637184de7d562d5fd50f (diff) | |
download | xen-c2c3d78cb84f1b47757cb3f5c1495ba662fae3a3.tar.gz xen-c2c3d78cb84f1b47757cb3f5c1495ba662fae3a3.tar.bz2 xen-c2c3d78cb84f1b47757cb3f5c1495ba662fae3a3.zip |
VT-d: protect against bogus information coming from BIOS
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>
master commit: e8e8b030ecf916fea19639f0b6a446c1c9dbe174
master date: 2013-08-14 11:18:24 +0200
-rw-r--r-- | xen/drivers/passthrough/vtd/dmar.c | 3 | ||||
-rw-r--r-- | xen/drivers/passthrough/vtd/iommu.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c index c810dbc531..8e162ff165 100644 --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -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; diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 0fc10de15b..d09b1c8cc4 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1159,6 +1159,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 ) |