All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Add sanity check for relocation entry pointer in execbuffer
@ 2025-06-16 14:22 Sebastian Brzezinka
  2025-06-17 10:01 ` Jani Nikula
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sebastian Brzezinka @ 2025-06-16 14:22 UTC (permalink / raw)
  To: intel-gfx; +Cc: chris.p.wilson, andi.shyti, krzysztof.niemiec, krzysztof.karas

This patch adds a defensive check in `eb_relocate_entry()` to validate
the relocation entry pointer before dereferencing it. It ensures the
pointer is non-NULL and accessible from userspace using `access_ok()`.

This prevents potential kernel crashes caused by invalid or non-canonical
pointers passed from userspace.

If the pointer is invalid, an error is logged and the
function returns -EFAULT.

The failure was observed on a Tiger Lake system while running the IGT
test `igt@gem_exec_big@single`. An appropriate patch has also been
submitted to fix the issue on the IGT side.

Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11713

Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index ca7e9216934a..8056dea0e656 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1427,6 +1427,12 @@ eb_relocate_entry(struct i915_execbuffer *eb,
 	struct eb_vma *target;
 	int err;
 
+	/* Sanity check for non-canonical or NULL pointer */
+	if (!reloc || !access_ok(reloc, sizeof(*reloc))) {
+		DRM_ERROR("Invalid relocation entry pointer: %p\n", reloc);
+		return -EFAULT;
+	}
+
 	/* we've already hold a reference to all valid objects */
 	target = eb_get_vma(eb, reloc->target_handle);
 	if (unlikely(!target))
-- 
2.34.1


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

end of thread, other threads:[~2025-06-18 10:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 14:22 [PATCH] drm/i915: Add sanity check for relocation entry pointer in execbuffer Sebastian Brzezinka
2025-06-17 10:01 ` Jani Nikula
2025-06-17 11:39 ` Tvrtko Ursulin
2025-06-18 10:15   ` Sebastian Brzezinka
2025-06-17 12:19 ` ✗ i915.CI.BAT: failure for " Patchwork
2025-06-17 13:11 ` [PATCH] " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.