Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] [PATCH v2] drm/i915/gem: Fix UAF race in eb_relocate_vma
@ 2026-03-24 15:17 Yassine Mounir
  2026-03-25  8:01 ` Joonas Lahtinen
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Yassine Mounir @ 2026-03-24 15:17 UTC (permalink / raw)
  To: gregkh; +Cc: intel-gfx, joonas.lahtinen, rodrigo.vivi, security,
	Yassine Mounir

Fix a race condition in Linux 7.0-rc2 where a GEM object could be freed
during relocation if userspace closes the handle concurrently.

The fix involves pinning the object lifetime using i915_gem_object_get()
before the relocation loop and releasing it via i915_gem_object_put()
in the common exit path (out label), ensuring symmetry in both success
and error paths.

This v2 rebases the change to the new 'gem/' directory structure in
the current mainline tree and addresses potential memory leaks in
early error returns.

Signed-off-by: Yassine Mounir <sosohero200@gmail.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index e7918f896..0468c0551 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1528,6 +1528,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 	if (unlikely(!access_ok(urelocs, remain * sizeof(*urelocs))))
 		return -EFAULT;
 
+	i915_gem_object_get(ev->vma->obj);
 	do {
 		struct drm_i915_gem_relocation_entry *r = stack;
 		unsigned int count =
@@ -1588,6 +1589,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 		urelocs += ARRAY_SIZE(stack);
 	} while (remain);
 out:
+	i915_gem_object_put(ev->vma->obj);
 	reloc_cache_reset(&eb->reloc_cache, eb);
 	return remain;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2026-04-13  4:39 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 15:17 [PATCH v2] [PATCH v2] drm/i915/gem: Fix UAF race in eb_relocate_vma Yassine Mounir
2026-03-25  8:01 ` Joonas Lahtinen
2026-03-25  8:20   ` Yassine Mounir
2026-03-25 14:07     ` Joonas Lahtinen
2026-03-25 15:43       ` Yassine Mounir
2026-03-25 15:46       ` Rodrigo Vivi
2026-03-25 17:30         ` Yassine Mounir
2026-03-25 17:30           ` Yassine Mounir
2026-03-25 22:14             ` Rodrigo Vivi
2026-03-25 22:37               ` Yassine Mounir
2026-03-26  6:54                 ` AI slop security report against i915 (Was: Re: [PATCH v2] drm/i915/gem: Fix UAF race in eb_relocate_vma) Joonas Lahtinen
2026-03-26  8:45                   ` Greg KH
2026-03-25 15:34 ` ✗ LGCI.VerificationFailed: failure for drm/i915/gem: Fix UAF race in eb_relocate_vma Patchwork
2026-03-26 12:32 ` [PATCH v2] [PATCH v2] " Ville Syrjälä
2026-03-26 15:19   ` Linus Torvalds
2026-04-03 22:12   ` Linus Torvalds
2026-04-03 22:35     ` Yassine Mounir
2026-04-03 22:38     ` Yassine Mounir
2026-04-07 16:38     ` Joonas Lahtinen
2026-04-07 16:46       ` Linus Torvalds
2026-04-08 11:15         ` Joonas Lahtinen
2026-04-08 15:38           ` Linus Torvalds
2026-04-08 16:24             ` Joonas Lahtinen
2026-04-09 15:45               ` Linus Torvalds
2026-04-13  4:39                 ` Joonas Lahtinen
2026-04-09  8:05         ` Matthew Brost
2026-04-09 15:50           ` Linus Torvalds
2026-04-07 16:58       ` Simona Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox