From: Matthew Auld <matthew.auld@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org, paulo.r.zanoni@intel.com
Subject: Re: [PATCH 2/2] drm/xe: Don't free job in TDR
Date: Thu, 3 Oct 2024 15:15:02 +0100 [thread overview]
Message-ID: <abf18240-7105-491a-962b-3db2d84dc897@intel.com> (raw)
In-Reply-To: <Zv6ksODQwzVvfOw3@DUT025-TGLU.fm.intel.com>
On 03/10/2024 15:05, Matthew Brost wrote:
> On Thu, Oct 03, 2024 at 08:06:24AM +0100, Matthew Auld wrote:
>> On 03/10/2024 01:16, Matthew Brost wrote:
>>> Freeing job in TDR is not safe as TDR can pass the run_job thread
>>> resulting in UAF. It is only safe for free job to naturally be called by
>>> the scheduler. Rather free job in TDR, add to pending list.
>>
>> s/Rather free/Rather than free/
>> ?
>>
>
> Yes, will fix.
>
>>>
>>> Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2811
>>> Cc: Matthew Auld <matthew.auld@intel.com>
>>> Fixes: e275d61c5f3f ("drm/xe/guc: Handle timing out of signaled jobs gracefully")
>>> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
>>
>> I think we still have the other issue with fence signalling in run_job.
>>
>
> I think this actually ok given free_job as owns a ref to job->fence and
> free_job now must run after run_job - that is why I didn't include this
> change in this patch. But I also agree a better design would be move the
> dma_fence_get from run_job to arm - I will do that in a follow up.
Here I mean the race in run_job() itself, before we hand over the fence
to the scheduler. i.e do the dma_fence_get() before the submission part
like in:
https://patchwork.freedesktop.org/patch/615249/?series=138921&rev=1.
>
> Matt
>
>> Reviewed-by: Matthew Auld <matthew.auld@intel.com>
>>
>>> ---
>>> drivers/gpu/drm/xe/xe_guc_submit.c | 7 +++++--
>>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
>>> index 80062e1d3f66..9ecd1661c1b5 100644
>>> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
>>> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
>>> @@ -1106,10 +1106,13 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)
>>> /*
>>> * TDR has fired before free job worker. Common if exec queue
>>> - * immediately closed after last fence signaled.
>>> + * immediately closed after last fence signaled. Add back to pending
>>> + * list so job can be freed and kick scheduler ensuring free job is not
>>> + * lost.
>>> */
>>> if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &job->fence->flags)) {
>>> - guc_exec_queue_free_job(drm_job);
>>> + xe_sched_add_pending_job(sched, job);
>>> + xe_sched_submission_start(sched);
>>> return DRM_GPU_SCHED_STAT_NOMINAL;
>>> }
next prev parent reply other threads:[~2024-10-03 14:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-03 0:16 [PATCH 0/2] TDR fixes Matthew Brost
2024-10-03 0:16 ` [PATCH 1/2] drm/xe: Take job list lock in xe_sched_add_pending_job Matthew Brost
2024-10-03 6:39 ` Matthew Auld
2024-10-03 0:16 ` [PATCH 2/2] drm/xe: Don't free job in TDR Matthew Brost
2024-10-03 7:06 ` Matthew Auld
2024-10-03 14:05 ` Matthew Brost
2024-10-03 14:15 ` Matthew Auld [this message]
2024-10-03 14:37 ` Matthew Brost
2024-10-03 15:10 ` Matthew Auld
2024-10-03 0:33 ` ✓ CI.Patch_applied: success for TDR fixes Patchwork
2024-10-03 0:34 ` ✓ CI.checkpatch: " Patchwork
2024-10-03 0:35 ` ✓ CI.KUnit: " Patchwork
2024-10-03 0:46 ` ✓ CI.Build: " Patchwork
2024-10-03 0:49 ` ✓ CI.Hooks: " Patchwork
2024-10-03 0:50 ` ✓ CI.checksparse: " Patchwork
2024-10-03 1:09 ` ✓ CI.BAT: " Patchwork
2024-10-03 2:11 ` ✗ CI.FULL: failure " Patchwork
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=abf18240-7105-491a-962b-3db2d84dc897@intel.com \
--to=matthew.auld@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=paulo.r.zanoni@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