iommu/arm-smmu-v3-sva: Fix mm use-after-free
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Tue, 26 Apr 2022 13:04:45 +0000 (14:04 +0100)
committerWill Deacon <will@kernel.org>
Fri, 6 May 2022 15:25:39 +0000 (16:25 +0100)
commitcbd23144f7662b00bcde32a938c4a4057e476d68
tree258cc5bf56bc772f6db3fef3915dbc3820f1bdf3
parentb131fa8c1d2afd05d0b7598621114674289c2fbb
iommu/arm-smmu-v3-sva: Fix mm use-after-free

We currently call arm64_mm_context_put() without holding a reference to
the mm, which can result in use-after-free. Call mmgrab()/mmdrop() to
ensure the mm only gets freed after we unpinned the ASID.

Fixes: 32784a9562fb ("iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Link: https://lore.kernel.org/r/20220426130444.300556-1-jean-philippe@linaro.org
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c