From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Rob Clark <robdclark@gmail.com>, dri-devel@lists.freedesktop.org
Cc: "Rob Clark" <robdclark@chromium.org>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Chris Wilson" <chris@chris-wilson.co.uk>,
"Andi Shyti" <andi.shyti@linux.intel.com>,
"John Harrison" <John.C.Harrison@Intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
katrinzhou <katrinzhou@tencent.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
intel-gfx@lists.freedesktop.org,
"open list" <linux-kernel@vger.kernel.org>,
"Niranjana Vishwanathapura" <niranjana.vishwanathapura@intel.com>,
"Matthew Auld" <matthew.auld@intel.com>
Subject: Re: [PATCH] drm/i915: Avoid potential vm use-after-free
Date: Mon, 23 Jan 2023 16:56:47 +0000 [thread overview]
Message-ID: <f24be4ca-edde-819a-5bcc-070e0d2e23d1@linux.intel.com> (raw)
In-Reply-To: <20230119173321.2825472-1-robdclark@gmail.com>
+ some more people based on e1a7ab4fca0c
On 19/01/2023 17:32, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
>
> Adding the vm to the vm_xa table makes it visible to userspace, which
> could try to race with us to close the vm. So we need to take our extra
> reference before putting it in the table.
>
> Signed-off-by: Rob Clark <robdclark@chromium.org>
> ---
> Note, you could list commit e1a7ab4fca0c ("drm/i915: Remove the vm open
> count") as the "fixed" commit, but really the issue seems to go back
> much further (with the fix needing some backporting in the process).
It would probably be rather essential to identify the correct Fixes: tag.
Since Thomas, Matt and Niranjana you were directly involved in the patch
which changed significantly how this works, perhaps there is something
still somewhat easily retrievable from your memory lanes to help with this?
Regards,
Tvrtko
>
> drivers/gpu/drm/i915/gem/i915_gem_context.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 6250de9b9196..e4b78ab4773b 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -1861,11 +1861,19 @@ static int get_ppgtt(struct drm_i915_file_private *file_priv,
> vm = ctx->vm;
> GEM_BUG_ON(!vm);
>
> + /*
> + * Get a reference for the allocated handle. Once the handle is
> + * visible in the vm_xa table, userspace could try to close it
> + * from under our feet, so we need to hold the extra reference
> + * first.
> + */
> + i915_vm_get(vm);
> +
> err = xa_alloc(&file_priv->vm_xa, &id, vm, xa_limit_32b, GFP_KERNEL);
> - if (err)
> + if (err) {
> + i915_vm_put(vm);
> return err;
> -
> - i915_vm_get(vm);
> + }
>
> GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
> args->value = id;
next prev parent reply other threads:[~2023-01-23 16:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 17:32 [PATCH] drm/i915: Avoid potential vm use-after-free Rob Clark
2023-01-23 16:56 ` Tvrtko Ursulin [this message]
2023-01-27 13:10 ` [Intel-gfx] " Matthew Auld
2023-01-27 13:50 ` Tvrtko Ursulin
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=f24be4ca-edde-819a-5bcc-070e0d2e23d1@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=John.C.Harrison@Intel.com \
--cc=airlied@gmail.com \
--cc=andi.shyti@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=katrinzhou@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=niranjana.vishwanathapura@intel.com \
--cc=robdclark@chromium.org \
--cc=robdclark@gmail.com \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/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