Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: "Tapani Pälli" <tapani.palli@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/xe: Fix NULL pointer dereference in xe_exec_ioctl
Date: Wed, 17 Dec 2025 13:04:58 -0800	[thread overview]
Message-ID: <aUMa+itbatz90kRY@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <c4776b5a-3396-4c0a-89c5-7a8b21e93028@intel.com>

On Wed, Dec 17, 2025 at 02:56:44PM +0000, Matthew Auld wrote:
> On 17/12/2025 13:24, Tapani Pälli wrote:
> > Helper function xe_sync_needs_wait expects sync->fence when accessing
> > flags, patch makes sure we call only when sync->fence exists.
> > 
> > v2: move null checking to xe_sync_needs_wait and make
> >      xe_sync_entry_wait utilize this helper (Matthew Auld)
> > v3: further simplify code (Matthew Auld)
> > 
> > Fixes NULL pointer dereference seen with Vulkan workloads:
> > 
> > [  118.410401] RIP: 0010:xe_sync_needs_wait+0x27/0x50 [xe]
> > 
> > Fixes: 4ac9048d0501 ("drm/xe: Wait on in-syncs when swicthing to dma-fence mode")
> > Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
> 
> To me this looks reasonable, but let's wait for Matt B and get his opinion
> here also, since he was the original author.
> 

It took me a minute to figure this one out,
DRM_XE_SYNC_TYPE_TIMELINE_SYNCOBJ can set the sync->fence to NULL if the
timeline point is signaled.

So yes, this looks correct.

Thanks for the fix!

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

Going to push this one now.

> Also thanks a lot for reporting, and fixing the issue,
> Reviewed-by: Matthew Auld <matthew.auld@intel.com>
> 
> > ---
> >   drivers/gpu/drm/xe/xe_sync.c | 10 ++++------
> >   1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_sync.c b/drivers/gpu/drm/xe/xe_sync.c
> > index ee1344a880b9..c8fdcdbd6ae7 100644
> > --- a/drivers/gpu/drm/xe/xe_sync.c
> > +++ b/drivers/gpu/drm/xe/xe_sync.c
> > @@ -238,10 +238,8 @@ int xe_sync_entry_add_deps(struct xe_sync_entry *sync, struct xe_sched_job *job)
> >    */
> >   int xe_sync_entry_wait(struct xe_sync_entry *sync)
> >   {
> > -	if (sync->flags & DRM_XE_SYNC_FLAG_SIGNAL)
> > -		return 0;
> > -
> > -	return dma_fence_wait(sync->fence, true);
> > +	return xe_sync_needs_wait(sync) ?
> > +		dma_fence_wait(sync->fence, true) : 0;
> >   }
> >   /**
> > @@ -252,8 +250,8 @@ int xe_sync_entry_wait(struct xe_sync_entry *sync)
> >    */
> >   bool xe_sync_needs_wait(struct xe_sync_entry *sync)
> >   {
> > -	return !(sync->flags & DRM_XE_SYNC_FLAG_SIGNAL) &&
> > -		!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &sync->fence->flags);
> > +	return sync->fence &&
> > +	       !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &sync->fence->flags);
> >   }
> >   void xe_sync_entry_signal(struct xe_sync_entry *sync, struct dma_fence *fence)
> 

  reply	other threads:[~2025-12-17 21:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17  6:17 [PATCH] drm/xe: Fix NULL pointer dereference in xe_exec_ioctl Tapani Pälli
2025-12-17  8:00 ` ✓ CI.KUnit: success for " Patchwork
2025-12-17  9:01 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-17 10:27 ` [PATCH] " Matthew Auld
2025-12-17 10:31   ` Matthew Auld
2025-12-17 10:51     ` Tapani Pälli
2025-12-17 11:42       ` Tapani Pälli
2025-12-17 11:51       ` Matthew Auld
2025-12-17 12:22         ` Tapani Pälli
2025-12-17 12:32           ` [PATCH v2] " Tapani Pälli
2025-12-17 12:57             ` Matthew Auld
2025-12-17 13:21               ` Tapani Pälli
2025-12-17 13:24                 ` [PATCH v3] " Tapani Pälli
2025-12-17 14:56                   ` Matthew Auld
2025-12-17 21:04                     ` Matthew Brost [this message]
2025-12-17 21:16           ` [PATCH] " Matthew Brost
2025-12-17 13:10 ` ✓ CI.KUnit: success for drm/xe: Fix NULL pointer dereference in xe_exec_ioctl (rev2) Patchwork
2025-12-17 13:48 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-17 15:43 ` ✓ CI.KUnit: success for drm/xe: Fix NULL pointer dereference in xe_exec_ioctl (rev3) Patchwork
2025-12-17 16:23 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-18 14:16 ` ✗ Xe.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=aUMa+itbatz90kRY@lstrano-desk.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=tapani.palli@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