Re: [PATCH] drm/i915/gem: Set the VM owner before publishing the VM

From: Joonas Lahtinen

Date: Fri Nov 20 2026 - 03:34:35 EST


Quoting Changyul Lee (2026-11-20 04:42:10)
> 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.

This commit message is just not making any sense.

The ID used in the supposed lookup is returned from this very IOCTL.

> Concurrent VM destruction can
> also free the VM before the owner assignment, causing a write to
> freed memory.

Could you explain in your own terms the call sequence that'll lead to
this?

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

Very LLM'esque to just explain what the code does to inflate the patch
description.

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

Unless a competent human developer looked the patches through before
submitting and wrote the patch descriptions, please redirect further
submissions to /dev/null.

Regards, Joonas

>
> 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
>