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 v6 1/3] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine
Date: Mon, 12 Oct 2026 09:43:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-167903@kernel.org> (raw)
In-Reply-To: <20261012093053.2103743-6-satyanarayana.k.v.p@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] timer: UAF and NULL pointer dereference due to un-synchronized timer_delete() on self-rearming timer
--
commit 6990383ed0fa291cb7a9714db126aaef3e32f00c
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 invalidates the engine name during teardown so subsequent scans
skip it, preventing VF memory IRQs from accessing a torn-down engine. It
modifies hw_engine_fini to clear the name and gt pointers under the irq
lock.
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
> index 265f95c0c8993..55ee0c892c1e8 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;
>
> - if (hwe->exl_port)
> - xe_execlist_port_destroy(hwe->exl_port);
> + if (hwe->exl_port)
> + xe_execlist_port_destroy(hwe->exl_port);
>
> - hwe->gt = NULL;
> + spin_lock_irqsave(&xe->irq.lock, flags);
> + hwe->name = NULL;
> + hwe->gt = NULL;
[Severity: High]
Does this code introduce a race condition with a self-rearming timer that can
lead to a NULL pointer dereference or use-after-free?
The xe_execlist_port_destroy() function, called just before this block, tears
down the execlist port but deletes the timer without synchronization:
drivers/gpu/drm/xe/xe_execlist.c:xe_execlist_port_destroy() {
...
timer_delete(&port->irq_fail);
...
}
However, the timer handler unconditionally rearms itself:
drivers/gpu/drm/xe/xe_execlist.c:xe_execlist_port_irq_fail_timer() {
...
port->irq_fail.expires = jiffies + msecs_to_jiffies(1000);
add_timer(&port->irq_fail);
}
If the timer is executing concurrently on another CPU during teardown,
timer_delete() returns immediately without waiting for the handler to finish.
The handler will then execute add_timer() at the end, defeating the deletion.
When the rearmed timer fires, it will eventually dereference port->hwe->gt.
Since hw_engine_fini() clears hwe->gt to NULL immediately after calling
xe_execlist_port_destroy(), could this result in a NULL pointer dereference?
Furthermore, since the port structure itself will eventually be freed when
the DRM device unbinds, could this lead to a use-after-free if the timer
persists?
Would it be safer to use a state flag, or replace timer_delete() with
timer_delete_sync() or timer_shutdown_sync() to safely tear down the
self-rearming timer?
> + spin_unlock_irqrestore(&xe->irq.lock, flags);
> + } else {
> + hwe->name = NULL;
> + }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012093053.2103743-5-satyanarayana.k.v.p@intel.com?part=1
next prev parent reply other threads:[~2026-10-12 9:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 9:30 [PATCH v6 0/3] Fix kernel crash during driver teardown Satyanarayana K V P
2026-10-12 9:30 ` [PATCH v6 1/3] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine Satyanarayana K V P
2026-10-12 9:43 ` sashiko-bot [this message]
2026-10-12 9:30 ` [PATCH v6 2/3] drm/xe/guc: Protect timeout handling from device unplug Satyanarayana K V P
2026-10-12 9:50 ` sashiko-bot
2026-10-12 9:30 ` [PATCH v6 3/3] drm/xe/gt: Disable GT reset worker before engine teardown Satyanarayana K V P
2026-10-12 15:12 ` ✓ CI.KUnit: success for Fix kernel crash during driver teardown (rev7) Patchwork
2026-10-12 17:37 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-12 19:54 ` [PATCH v6 0/3] Fix kernel crash during driver teardown Rodrigo Vivi
2026-10-12 19:55 ` ✓ Xe.CI.FULL: success for Fix kernel crash during driver teardown (rev7) 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-167903@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox