]> www.infradead.org Git - users/dwmw2/linux.git/commit
iommu/amd: Fix race in increase_address_space()
authorJoerg Roedel <jroedel@suse.de>
Fri, 6 Sep 2019 08:39:54 +0000 (10:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Sep 2019 05:18:50 +0000 (07:18 +0200)
commit785ca708a908b9c596ede852470ba28b8dc3e40b
tree303cccb32358e1a67d5865ec9c416ad7c5f965c1
parented52f6cf0e84ab34b2f1fa4bc865be941ec606cd
iommu/amd: Fix race in increase_address_space()

[ Upstream commit 754265bcab78a9014f0f99cd35e0d610fcd7dfa7 ]

After the conversion to lock-less dma-api call the
increase_address_space() function can be called without any
locking. Multiple CPUs could potentially race for increasing
the address space, leading to invalid domain->mode settings
and invalid page-tables. This has been happening in the wild
under high IO load and memory pressure.

Fix the race by locking this operation. The function is
called infrequently so that this does not introduce
a performance regression in the dma-api path again.

Reported-by: Qian Cai <cai@lca.pw>
Fixes: 256e4621c21a ('iommu/amd: Make use of the generic IOVA allocator')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/amd_iommu.c