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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:14 +0000 (10:23 +0200)
commitfc90f13ea0dcd960e5002d204fa55cec4e0db2fa
treeac5e19d77d7fb6b4a4b5f94b376c8b81a4d26b3e
parent2f124280f0aed93b6fadc64ccb51c670f088150d
iommu/arm-smmu-v3-sva: Fix mm use-after-free

[ Upstream commit cbd23144f7662b00bcde32a938c4a4057e476d68 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c