]> www.infradead.org Git - users/dwmw2/linux.git/commit
iommu/vt-d: Limit max address mask to MAX_AGAW_PFN_WIDTH
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 9 Jul 2024 15:26:42 +0000 (23:26 +0800)
committerWill Deacon <will@kernel.org>
Wed, 10 Jul 2024 12:06:55 +0000 (13:06 +0100)
commitc420a2b4e8be06f16f3305472bd25a1dd12059ec
tree865cf5562b14bfa7eb6db62106542ed6e60b6a54
parent3753311c9190f833963fb47336dfe17221d93706
iommu/vt-d: Limit max address mask to MAX_AGAW_PFN_WIDTH

Address mask specifies the number of low order bits of the address field
that must be masked for the invalidation operation.

Since address bits masked start from bit 12, the max address mask should
be MAX_AGAW_PFN_WIDTH, as defined in Table 19 ("Invalidate Descriptor
Address Mask Encodings") of the spec.

Limit the max address mask returned from calculate_psi_aligned_address()
to MAX_AGAW_PFN_WIDTH to prevent potential integer overflow in the
following code:

qi_flush_dev_iotlb():
    ...
    addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1;
    ...

Fixes: c4d27ffaa8eb ("iommu/vt-d: Add cache tag invalidation helpers")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20240709152643.28109-2-baolu.lu@linux.intel.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/intel/cache.c