Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yassine Mounir <sosohero200@gmail.com>
To: gregkh@linuxfoundation.org
Cc: intel-gfx@lists.freedesktop.org, joonas.lahtinen@linux.intel.com,
	rodrigo.vivi@intel.com, security@kernel.org,
	Yassine Mounir <sosohero200@gmail.com>
Subject: [PATCH v2] [PATCH v2] drm/i915/gem: Fix UAF race in eb_relocate_vma
Date: Tue, 24 Mar 2026 11:17:41 -0400	[thread overview]
Message-ID: <20260324151741.29338-1-sosohero200@gmail.com> (raw)

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


             reply	other threads:[~2026-03-25 11:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24 15:17 Yassine Mounir [this message]
2026-03-25  8:01 ` [PATCH v2] [PATCH v2] drm/i915/gem: Fix UAF race in eb_relocate_vma 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260324151741.29338-1-sosohero200@gmail.com \
    --to=sosohero200@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=security@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox