VT-d: protect against bogus information coming from BIOS
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_heaif ( (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_heaif ( (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
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.
Signed-off-by Jan Beulich <[email protected]>
Quoted 28 lines
xen/drivers/passthrough/vtd/dmar.c +3
-0@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_heaif ( (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 )
Ping: [PATCH] VT-d: protect against bogus information coming from BIOS
In reply to Jan BeulichPing?
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.
Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/vtd/dmar.c +3
-0@@ -447,6 +447,9 @@ acpi_parse_one_drhd(struct acpi_dmar_heaif ( (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 )
Ben Guthro
Reviewed-byRe: 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.
Signed-off-by Jan Beulich <[email protected]>
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_heaif ( (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_SIZEQuoted 2 lines
||
ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Andrew Cooper
Reviewed-byRe: Ping: [PATCH] VT-d: protect against bogus information coming from BIOS
In reply to Jan BeulichQuoted 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.
Signed-off-by Jan Beulich <[email protected]>
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_heaif ( (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