Skip to contentSkip to conversation

VT-d: protect against bogus information coming from BIOS

PATCH In review Jan Beulich 3 participants 5 messages Jul 10, 2013 – Aug 5, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

xen/drivers/passthrough/vtd/dmar.c +3 -0
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_hea
     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;
xen/drivers/passthrough/vtd/iommu.c +3 -0
@@ -1159,6 +1159,9 @@ int __init iommu_alloc(struct acpi_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 )

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.

xen/drivers/passthrough/vtd/dmar.c +3 -0
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_hea
     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;
xen/drivers/passthrough/vtd/iommu.c +3 -0
@@ -1159,6 +1159,9 @@ int __init iommu_alloc(struct acpi_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 )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

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.

Quoted 28 lines
xen/drivers/passthrough/vtd/dmar.c +3 -0
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_hea
     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;
xen/drivers/passthrough/vtd/iommu.c +3 -0
@@ -1159,6 +1159,9 @@ int __init iommu_alloc(struct acpi_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 )
#2 lore raw

Ping: [PATCH] VT-d: protect against bogus information coming from BIOS

In reply to Jan Beulich

Ping?

Quoted 32 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

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.

xen/drivers/passthrough/vtd/dmar.c +3 -0
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_hea
     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;
xen/drivers/passthrough/vtd/iommu.c +3 -0
@@ -1159,6 +1159,9 @@ int __init iommu_alloc(struct acpi_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 )
Reviewed-by
#3 lore raw

Re: Ping: [PATCH] VT-d: protect against bogus information coming from BIOS

Quoted 10 lines · Jan Beulich

Ping?

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

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.

Looks OK to me, FWIW

You can add

Quoted 18 lines
Quoted 15 lines
xen/drivers/passthrough/vtd/dmar.c +3 -0
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_hea
     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;

xen/drivers/passthrough/vtd/iommu.c int __init iommu_alloc(struct acpi_drhd_ · line 1160

Quoted 2 lines
xen/drivers/passthrough/vtd/iommu.c +0 -0
@@ -1159,6 +1159,9 @@ int __init iommu_alloc(struct acpi_drhd_
         dprintk(VTDPREFIX,
                 "cap = %"PRIx64" ecap = %"PRIx64"\n", iommu->cap,

iommu->ecap);

Quoted 13 lines

xen/drivers/passthrough/vtd/iommu.c int __init iommu_alloc(struct acpi_drhd_

Quoted 6 lines
xen/drivers/passthrough/vtd/iommu.c +3 -0
     }
+    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

Quoted 2 lines

||

          ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by
#4 lore raw

Re: Ping: [PATCH] VT-d: protect against bogus information coming from BIOS

In reply to Jan Beulich
Quoted 8 lines · Jan Beulich

Ping?

Quoted 6 lines
Quoted 1 line
Quoted 1 line · Jan Beulich

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.

Quoted 33 lines
Quoted 25 lines
xen/drivers/passthrough/vtd/dmar.c +3 -0
@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_hea
     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;
xen/drivers/passthrough/vtd/iommu.c +3 -0
@@ -1159,6 +1159,9 @@ int __init iommu_alloc(struct acpi_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 

||

Quoted 1 line
          ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel