]> git.baikalelectronics.ru Git - kernel.git/commit
iommu/dma: Fix MSI reservation allocation
authorMarc Zyngier <maz@kernel.org>
Wed, 4 Mar 2020 11:11:17 +0000 (11:11 +0000)
committerJoerg Roedel <jroedel@suse.de>
Wed, 4 Mar 2020 15:27:56 +0000 (16:27 +0100)
commite82ada738e1f80cc82eeaf94f9e42c9201cccbeb
tree2f91980eccf8ab0191dc811e71b02510d0fa3b7c
parent48f1710d84672693643e124ac6f710e4779964a6
iommu/dma: Fix MSI reservation allocation

The way cookie_init_hw_msi_region() allocates the iommu_dma_msi_page
structures doesn't match the way iommu_put_dma_cookie() frees them.

The former performs a single allocation of all the required structures,
while the latter tries to free them one at a time. It doesn't quite
work for the main use case (the GICv3 ITS where the range is 64kB)
when the base granule size is 4kB.

This leads to a nice slab corruption on teardown, which is easily
observable by simply creating a VF on a SRIOV-capable device, and
tearing it down immediately (no need to even make use of it).
Fortunately, this only affects systems where the ITS isn't translated
by the SMMU, which are both rare and non-standard.

Fix it by allocating iommu_dma_msi_page structures one at a time.

Fixes: eaa95d7632f8a ("iommu/dma: Handle IOMMU API reserved regions")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Will Deacon <will@kernel.org>
Cc: stable@vger.kernel.org
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/dma-iommu.c