Skip to contentSkip to conversation

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

DISCUSSION Jan Beulich 3 participants 4 messages Aug 13, 2013 – Aug 14, 2013

lore
Share & tools
lore
#0 lore raw

The first ping was sent over a week ago, and I'll assume silent agreement if I won't hear back otherwise in a day or two. (I would, btw, have wanted this to also go into 4.2.3 and 4.1.6, but likely it's going to be too late now for this, and thus for the 4.1 branch altogether.)

Jan

Quoted 31 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 )
#1 lore raw

Jan Beulich wrote on 2013-08-13:

Quoted 23 lines

The first ping was sent over a week ago, and I'll assume silent agreement if I won't hear back otherwise in a day or two. (I would, btw, have wanted this to also go into 4.2.3 and 4.1.6, but likely it's going to be too late now for this, and thus for the 4.1 branch altogether.)

Jan

Quoted 16 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);
Quoted 15 lines

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

Quoted 7 lines
xen/drivers/passthrough/vtd/dmar.c +0 -0
     if ( !dmaru )
         return -ENOMEM;
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 7 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 || ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )

Acked by: Yang Zhang <[email protected]>

Best regards,
Yang

#2 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Yang Z

Jan Beulich wrote on 2013-08-13:

Quoted 4 lines

The first ping was sent over a week ago, and I'll assume silent agreement if I won't hear back otherwise in a day or two. (I would, btw, have wanted this to also go into 4.2.3 and 4.1.6, but likely it's going to be too late now for this, and thus for the 4.1 branch altogether.)

Acked by: Yang Zhang <[email protected]>

I appreciate your ack, but only Xiantao is listed as VT-d maintainer, i.e. your ack is only an extra confirmation.

Regards, Jan

#3 lore raw

Thanks! Acked-by: Xiantao Zhang <[email protected]> Xiantao

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, August 14, 2013 4:22 PM
To: Zhang, Xiantao; Zhang, Yang Z
Cc: Ben Guthro; xen-devel
Subject: RE: [Xen-devel] Ping #2: [PATCH] VT-d: protect against bogus information coming from BIOS

Quoted 8 lines
Quoted 1 line
Quoted 1 line · Yang Z

Jan Beulich wrote on 2013-08-13:

Quoted 5 lines

The first ping was sent over a week ago, and I'll assume silent agreement if I won't hear back otherwise in a day or two. (I would, btw, have wanted this to also go into 4.2.3 and 4.1.6, but likely it's going to be too late now for this, and thus for the 4.1 branch altogether.)

Acked by: Yang Zhang <[email protected]>

I appreciate your ack, but only Xiantao is listed as VT-d maintainer, i.e. your ack is only an extra confirmation.

Regards, Jan