All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Satyanarayana K V P" <satyanarayana.k.v.p@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v3 1/3] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine
Date: Fri, 09 Oct 2026 12:29:54 +0000	[thread overview]
Message-ID: <sashiko-outbox-165540@kernel.org> (raw)
In-Reply-To: <20261009121921.818671-6-satyanarayana.k.v.p@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] drm/xe: NULL Pointer Dereference in xe_execlist_port_destroy and timer due to early hwe->gt clearing
--

commit 0f76e8a7471aad3de71482c37a1644b32699ef4e
Author: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>

drm/xe: Prevent VF memory IRQ from accessing a torn-down engine

The commit fixes a NULL pointer dereference by invalidating the engine name
and clearing hwe->gt earlier in the teardown process. However, this
reordering appears to introduce a new issue where xe_execlist_port_destroy()
encounters a NULL pointer.

> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
> index 9680d2a5adec7..3a6b9a4fe63ff 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.c
> @@ -275,11 +275,22 @@ static const struct engine_info engine_infos[] = {
>  static void hw_engine_fini(void *arg)
>  {
>  	struct xe_hw_engine *hwe = arg;
> +	struct xe_gt *gt = hwe->gt;
> +
> +	if (gt) {
> +		struct xe_device *xe = gt_to_xe(gt);
> +		unsigned long flags;
> +
> +		spin_lock_irqsave(&xe->irq.lock, flags);
> +		hwe->name = NULL;
> +		hwe->gt = NULL;
> +		spin_unlock_irqrestore(&xe->irq.lock, flags);
> +	} else {
> +		hwe->name = NULL;
> +	}
>  
>  	if (hwe->exl_port)
>  		xe_execlist_port_destroy(hwe->exl_port);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: Critical]
Will this call to xe_execlist_port_destroy() cause a kernel panic now that
hwe->gt has been cleared to NULL?

Looking at xe_execlist_port_destroy() in drivers/gpu/drm/xe/xe_execlist.c, it
dereferences port->hwe->gt:

void xe_execlist_port_destroy(struct xe_execlist_port *port)
{
	timer_delete(&port->irq_fail);

	/* Prevent an interrupt while we're destroying */
	spin_lock_irq(&gt_to_xe(port->hwe->gt)->irq.lock);
	...
}

Because hwe->gt is set to NULL right before this call, gt_to_xe(NULL) will
dereference a NULL pointer (specifically gt_to_tile(NULL)->xe) when acquiring
the spinlock.

This problem wasn't introduced by this patch, but doesn't calling
timer_delete() instead of timer_delete_sync() on port->irq_fail allow the
timer to execute concurrently during or after destruction? If the timer
fires and calls read_execlist_status(port->hwe) which also accesses hwe->gt,
would it hit the same NULL pointer dereference now that the pointer is cleared
earlier?

> -
> -	hwe->gt = NULL;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009121921.818671-5-satyanarayana.k.v.p@intel.com?part=1

  reply	other threads:[~2026-10-09 12:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 12:19 [PATCH v3 0/3] Fix kernel crash during driver teardown Satyanarayana K V P
2026-10-09 12:19 ` [PATCH v3 1/3] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine Satyanarayana K V P
2026-10-09 12:29   ` sashiko-bot [this message]
2026-10-09 12:19 ` [PATCH v3 2/3] drm/xe/guc: Protect timeout handling from device unplug Satyanarayana K V P
2026-10-09 12:19 ` [PATCH v3 3/3] drm/xe/gt: Disable GT reset worker before engine teardown Satyanarayana K V P
2026-10-09 12:39   ` sashiko-bot
2026-10-09 13:07 ` ✓ CI.KUnit: success for Fix kernel crash during driver teardown (rev3) Patchwork
2026-10-09 14:34 ` ✓ Xe.CI.BAT: " 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=sashiko-outbox-165540@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=satyanarayana.k.v.p@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.