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 1/1] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine
Date: Thu, 08 Oct 2026 12:36:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-164158@kernel.org> (raw)
In-Reply-To: <20261008122543.390356-4-satyanarayana.k.v.p@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] xe: TOCTOU race in hw_engine_fini() allows NULL pointer dereference despite hwe->name invalidation
--
commit 582041e3254f04e73ce6e909225432f284799ee4
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 attempts to fix a NULL pointer dereference in the VF memory IRQ
handler by clearing hwe->name before hwe->gt during engine teardown, aiming
to have the handler skip the torn-down engine.
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
> index 9680d2a5adec7..2267249c26894 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.c
> @@ -279,6 +279,7 @@ static void hw_engine_fini(void *arg)
> if (hwe->exl_port)
> xe_execlist_port_destroy(hwe->exl_port);
>
> + hwe->name = NULL;
> hwe->gt = NULL;
[Severity: High]
Does this leave a Time-Of-Check to Time-Of-Use (TOCTOU) race window that
still allows a NULL pointer dereference?
Because xe_irq_install() is called before xe_gt_init() in xe_device_probe(),
and devm actions execute in LIFO order, hw_engine_fini() can run while
hardware interrupts are still active.
If an interrupt fires concurrently with teardown, the VF memory IRQ handler
xe_memirq_handler() iterates locklessly and can observe a valid hwe->name
via xe_hw_engine_is_valid():
drivers/gpu/drm/xe/xe_memirq.c:xe_memirq_handler() {
...
for_each_hw_engine(hwe, gt, id)
xe_memirq_hwe_handler(memirq, hwe);
...
}
Concurrently, hw_engine_fini() clears both hwe->name and hwe->gt without any
locks or memory barriers. The IRQ handler then proceeds to dereference the
now-NULL hwe->gt:
drivers/gpu/drm/xe/xe_hw_engine.c:xe_hw_engine_handle_irq() {
...
wake_up_all(>_to_xe(hwe->gt)->ufence_wq);
...
}
Furthermore, the lack of memory barriers (such as WRITE_ONCE and
smp_store_release) allows the CPU or compiler to reorder the nullification
of name and gt, widening the race window.
Is proper synchronization (such as synchronize_irq(), locking, or disabling
IRQs prior to engine teardown) required here to safely close the race?
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008122543.390356-3-satyanarayana.k.v.p@intel.com?part=1
next prev parent reply other threads:[~2026-10-08 12:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 12:25 [PATCH 0/1] Fix kernel crash during driver teardown Satyanarayana K V P
2026-10-08 12:25 ` [PATCH 1/1] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine Satyanarayana K V P
2026-10-08 12:36 ` sashiko-bot [this message]
2026-10-08 12:57 ` Piotr Piórkowski
2026-10-08 12:36 ` ✓ CI.KUnit: success for Fix kernel crash during driver teardown Patchwork
2026-10-08 13:16 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-08 15:21 ` ✗ 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=sashiko-outbox-164158@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