Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Zakaria Belkadi <zakaria.belkadi@inria.fr>,
	stable@vger.kernel.org,
	Matthew Auld <matthew.william.auld@gmail.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Tvrtko Ursulin <tursulin@ursulin.net>
Subject: [PATCH] drm/i915: Reject relocation writes to RO userptr
Date: Thu, 26 Nov 2026 11:44:44 +0200	[thread overview]
Message-ID: <20261126094444.52858-1-joonas.lahtinen@linux.intel.com> (raw)

Read-only userptr BOs shouldn't be allowed to have relocation
addresses written back to them. Enforce that.

The relocation slow path where this could have happened has been
in place, reverted and then re-introduced. GPU relocations path
protected against this via ppGTT flags was also reverted at point.

There's no legimate use-case for this, so instead of trying to track
which kernel versions were impacted and which not, just outright
reject with EFAULT on all kernels with RO userptr support.

Reported-by: Zakaria Belkadi <zakaria.belkadi@inria.fr>
Fixes: 0b100760e3e8 ("drm/i915/userptr: Enable read-only support on gen8+")
Cc: <stable@vger.kernel.org> # v4.19+
Cc: Matthew Auld <matthew.william.auld@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index c41e1b9a40bc..7ed23dc392b8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -511,6 +511,10 @@ eb_validate_vma(struct i915_execbuffer *eb,
 	if (unlikely(entry->flags & eb->invalid_flags))
 		return -EINVAL;
 
+	if (unlikely(i915_gem_object_is_readonly(vma->obj) &&
+		     entry->relocation_count))
+		return -EFAULT;
+
 	if (unlikely(entry->alignment &&
 		     !is_power_of_2_u64(entry->alignment)))
 		return -EINVAL;
-- 
2.56.1


                 reply	other threads:[~2026-11-26  9:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261126094444.52858-1-joonas.lahtinen@linux.intel.com \
    --to=joonas.lahtinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=matthew.william.auld@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tursulin@ursulin.net \
    --cc=zakaria.belkadi@inria.fr \
    /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