From: Matthew Brost <matthew.brost@intel.com>
To: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH] drm/xe: Free job before xe_exec_queue_put
Date: Wed, 21 Aug 2024 15:23:30 +0000 [thread overview]
Message-ID: <ZsYGch0IF0JYpKT2@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <2279a661-6dab-44e6-beac-55ab47e1e5c4@intel.com>
On Wed, Aug 21, 2024 at 11:52:26AM +0530, Ghimiray, Himal Prasad wrote:
>
>
> On 21-08-2024 01:53, Matthew Brost wrote:
> > Free job depends on job->vm being valid, the last xe_exec_queue_put can
> > destroy the VM. Prevent UAF by freeing job before xe_exec_queue_put.
>
>
> Seems this order needs to be fixed also in error handling/cleanup of
> xe_sched_job_create.
>
We should likely have an additional exec queue ref from the outer layers
when creating jobs but for uniformity agree that should be changed too.
Will post a follow up for that.
Matt
>
> >
> > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_sched_job.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_sched_job.c b/drivers/gpu/drm/xe/xe_sched_job.c
> > index 44d534e362cd..9628f9deb3c0 100644
> > --- a/drivers/gpu/drm/xe/xe_sched_job.c
> > +++ b/drivers/gpu/drm/xe/xe_sched_job.c
> > @@ -171,12 +171,13 @@ void xe_sched_job_destroy(struct kref *ref)
> > struct xe_sched_job *job =
> > container_of(ref, struct xe_sched_job, refcount);
> > struct xe_device *xe = job_to_xe(job);
> > + struct xe_exec_queue *q = job->q;
> > xe_sched_job_free_fences(job);
> > - xe_exec_queue_put(job->q);
> > dma_fence_put(job->fence);
> > drm_sched_job_cleanup(&job->drm);
> > job_free(job);
> > + xe_exec_queue_put(q);
> > xe_pm_runtime_put(xe);
> > }
prev parent reply other threads:[~2024-08-21 15:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 20:23 [PATCH] drm/xe: Free job before xe_exec_queue_put Matthew Brost
2024-08-20 20:27 ` Nirmoy Das
2024-08-20 20:36 ` ✓ CI.Patch_applied: success for " Patchwork
2024-08-20 20:36 ` ✓ CI.checkpatch: " Patchwork
2024-08-20 20:37 ` ✓ CI.KUnit: " Patchwork
2024-08-20 20:55 ` ✓ CI.Build: " Patchwork
2024-08-20 20:57 ` ✓ CI.Hooks: " Patchwork
2024-08-20 20:59 ` ✓ CI.checksparse: " Patchwork
2024-08-20 21:03 ` [PATCH] " Randhawa, Jagmeet
2024-08-20 21:35 ` ✓ CI.BAT: success for " Patchwork
2024-08-21 4:24 ` ✗ CI.FULL: failure " Patchwork
2024-08-21 6:22 ` [PATCH] " Ghimiray, Himal Prasad
2024-08-21 15:23 ` Matthew Brost [this message]
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=ZsYGch0IF0JYpKT2@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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