Skip to contentSkip to conversation

drm/i915/gem: Fix relocation race and simplify VMA lookup

PATCH Superseded Yassine Mounir 1 participant 1 message Apr 8

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/i915/gem: Fix relocation race and simplify VMA lookup

Pin the object lifetime in eb_relocate_vma() using i915_gem_object_get() and i915_gem_object_put() to prevent a Use-After-Free (UAF) if the handle is closed concurrently during relocation.

Additionally, simplify eb_lookup_vma() by removing the redundant vma->vm == vm check. As noted by Joonas, this check is unnecessary since commit d4433c7600f7. Removing it also avoids the "insane" logic of returning a VMA without a reference, satisfying the sanity requirements requested by Linus.

Fixes d4433c7600f7 ("drm/i915: Multi-vm support")
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +1 -1
index 942f4eed8..65ce54b20 100644
@@ -896,7 +896,7 @@ static struct i915_vma *eb_lookup_vma(struct i915_execbuffer *eb, u32 handle)
 
 		rcu_read_lock();
 		vma = radix_tree_lookup(&eb->gem_context->handles_vma, handle);
-		if (likely(vma && vma->vm == vm))
+		if (likely(vma))
 			vma = i915_vma_tryget(vma);
 		else
 			vma = NULL;
Signature · 1 line
2.51.0