intel_iommu: Check address mask before using it in pasid-based iotlb invalidation
PATCH v2 1/1 intel_iommu: Check address mask before using it in pasid-based iotlb invalidation
Prevent a buggy driver to execute malformed invalidation operations.
Add the same assert as in vtd_iotlb_page_invalidate.
Fixes 6ebe6cf2a066 ("intel_iommu: Process PASID-based iotlb invalidation")
Signed-off-by Clement Mathieu--Drif <[email protected]>
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Reviewed-by Zhenzhong Duan <[email protected]>
--- hw/i386/intel_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/i386/intel_iommu.c +9 -0
@@ -3021,6 +3021,8 @@ static void vtd_piotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, {VTDIOTLBPageInvInfo info; +assert (am <=VTD_MAMV ); + info.domain_id = domain_id; info.pasid = pasid; info.addr = addr;
@@ -3060,6 +3062,13 @@ static bool vtd_process_piotlb_desc(IntelIOMMUState *s,case VTD_INV_DESC_PIOTLB_PSI_IN_PASID : am =VTD_INV_DESC_PIOTLB_AM (inv_desc->val[1 ]); +if (am >VTD_MAMV ) { +error_report_once ("%s: invalid piotlb inv desc: hi=0x%" PRIx64 +", lo=0x%" PRIx64" (am=%u > VTD_MAMV=%llu)" , + __func__, inv_desc->val[1 ], inv_desc->val[0 ], + am,VTD_MAMV ); +return false; + } addr = (hwaddr )VTD_INV_DESC_PIOTLB_ADDR (inv_desc->val[1 ]);vtd_piotlb_page_invalidate (s, domain_id, pasid, addr, am,VTD_INV_DESC_PIOTLB_IH (inv_desc));
Signature · 1 line
2.54.0
Quoted 10 lines · Clément MATHIEU--DRIF
Prevent a buggy driver to execute malformed invalidation operations.
Add the same assert as in
vtd_iotlb_page_invalidate.Fixes 6ebe6cf2a066 ("intel_iommu: Process PASID-based iotlb invalidation")Signed-off-by Clement Mathieu--Drif <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Zhenzhong Duan <[email protected]>---
changelog in the future pls.
Quoted 32 lines
hw/i386/intel_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/i386/intel_iommu.c +9
-0@@ -3021,6 +3021,8 @@ static void vtd_piotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, {VTDIOTLBPageInvInfo info; +assert (am <=VTD_MAMV ); + info.domain_id = domain_id; info.pasid = pasid; info.addr = addr;@@ -3060,6 +3062,13 @@ static bool vtd_process_piotlb_desc(IntelIOMMUState *s,case VTD_INV_DESC_PIOTLB_PSI_IN_PASID : am =VTD_INV_DESC_PIOTLB_AM (inv_desc->val[1 ]); +if (am >VTD_MAMV ) { +error_report_once ("%s: invalid piotlb inv desc: hi=0x%" PRIx64 +", lo=0x%" PRIx64" (am=%u > VTD_MAMV=%llu)" , + __func__, inv_desc->val[1 ], inv_desc->val[0 ], + am,VTD_MAMV ); +return false; + } addr = (hwaddr )VTD_INV_DESC_PIOTLB_ADDR (inv_desc->val[1 ]);vtd_piotlb_page_invalidate (s, domain_id, pasid, addr, am,VTD_INV_DESC_PIOTLB_IH (inv_desc));Signature · 1 line
2.54.0
Quoted 17 lines · Michael S. Tsirkin
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Quoted 10 lines · Clément MATHIEU--DRIF
Prevent a buggy driver to execute malformed invalidation operations.
Add the same assert as in
vtd_iotlb_page_invalidate.Fixes 6ebe6cf2a066 ("intel_iommu: Process PASID-based iotlb invalidation")---
Quoted 1 line
changelog in the future pls.
Yep, my bad, thanks Michael
Quoted 36 lines
Quoted 34 lines
hw/i386/intel_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/i386/intel_iommu.c +9
-1@@ -3021,6 +3021,8 @@ static void vtd_piotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, {VTDIOTLBPageInvInfo info; +assert (am <=VTD_MAMV ); + info.domain_id = domain_id; info.pasid = pasid; info.addr = addr;@@ -3060,6 +3062,13 @@ static bool vtd_process_piotlb_desc(IntelIOMMUState *s,case VTD_INV_DESC_PIOTLB_PSI_IN_PASID : am =VTD_INV_DESC_PIOTLB_AM (inv_desc->val[1 ]); +if (am >VTD_MAMV ) { +error_report_once ("%s: invalid piotlb inv desc: hi=0x%" PRIx64 +", lo=0x%" PRIx64" (am=%u > VTD_MAMV=%llu)" , + __func__, inv_desc->val[1 ], inv_desc->val[0 ], + am,VTD_MAMV ); +return false; + } addr = (hwaddr )VTD_INV_DESC_PIOTLB_ADDR (inv_desc->val[1 ]);vtd_piotlb_page_invalidate (s, domain_id, pasid, addr, am,VTD_INV_DESC_PIOTLB_IH (inv_desc)); --2.54.0