mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/i915/gem: Set the VM owner before publishing the VM
@ 2026-11-20  2:42 Changyul Lee
  0 siblings, 0 replies; only message in thread
From: Changyul Lee @ 2026-11-20  2:42 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Simona Vetter
  Cc: Aravind Iddamsetty, intel-gfx, dri-devel, linux-kernel, Changyul Lee

i915_gem_vm_create_ioctl() adds the VM to the file's VM table before
setting its owner (vm.fpriv). A concurrent lookup can therefore see
the VM without an owner and allocate page tables that are missing
from the client's memory accounting. Concurrent VM destruction can
also free the VM before the owner assignment, causing a write to
freed memory.

Set the owner before inserting the VM into the table with xa_alloc().
If xa_alloc() fails, err_put still releases the VM.

Fixes: ca02a0119f81 ("drm/i915: Record which client owns a VM")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
Found with a static analysis tool we are developing.

Compile-tested only, with x86_64_defconfig and W=1.

 drivers/gpu/drm/i915/gem/i915_gem_context.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index c58ffa5a8fa6..489b221091d1 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1838,6 +1838,8 @@ int i915_gem_vm_create_ioctl(struct drm_device *dev, void *data,
 			goto err_put;
 	}
 
+	ppgtt->vm.fpriv = file_priv;
+
 	err = xa_alloc(&file_priv->vm_xa, &id, &ppgtt->vm,
 		       xa_limit_32b, GFP_KERNEL);
 	if (err)
@@ -1845,7 +1847,6 @@ int i915_gem_vm_create_ioctl(struct drm_device *dev, void *data,
 
 	GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
 	args->vm_id = id;
-	ppgtt->vm.fpriv = file_priv;
 	return 0;
 
 err_put:

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20  2:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  2:42 [PATCH] drm/i915/gem: Set the VM owner before publishing the VM Changyul Lee

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

all inboxes | Powered by JetHome®