]> git.itanic.dy.fi Git - linux-stable/commit
drm/i915: Fix a race between vma / object destruction and unbinding
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 27 Jan 2022 11:56:22 +0000 (12:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Jul 2022 14:35:07 +0000 (16:35 +0200)
commit51a405dea0ae54330b6441c5f7c3bb9ceadedce8
tree5250abcfe95629ca520d38e1ae088de6e24c7f4d
parent7a9e13b86536ce6dca54380f19d537b1c80caee3
drm/i915: Fix a race between vma / object destruction and unbinding

[ Upstream commit bc1922e5d349db4be14c55513102c024c2ae8a50 ]

The vma destruction code was using an unlocked advisory check for
drm_mm_node_allocated() to avoid racing with eviction code unbinding
the vma.

This is very fragile and prohibits the dereference of non-refcounted
pointers of dying vmas after a call to __i915_vma_unbind(). It also
prohibits the dereference of vma->obj of refcounted pointers of
dying vmas after a call to __i915_vma_unbind(), since even if a
refcount is held on the vma, that won't guarantee that its backing
object doesn't get destroyed.

So introduce an unbind under the vm mutex at object destroy time,
removing all weak references of the vma and its object from the
object vma list and from the vm bound list.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220127115622.302970-1-thomas.hellstrom@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/i915/gem/i915_gem_object.c