From: sashiko-bot@kernel.org
To: "Umesh Nerlige Ramappa" <umesh.nerlige.ramappa@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/xe/guc: Reject a duplicate deregister-done G2H
Date: Tue, 08 Sep 2026 23:32:45 +0000 [thread overview]
Message-ID: <20260908233245.E6BB71F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908231854.1218934-5-umesh.nerlige.ramappa@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Preexisting TOCTOU Use-After-Free race in G2H handlers due to lockless XArray lookup and immediate kfree() of xe_exec_queue.
--
commit 7071b18636a4e1a16b055aa587e7944a18af7e7e
Author: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
drm/xe/guc: Reject a duplicate deregister-done G2H
This commit adds a check to reject duplicate deregister-done G2H messages
during the window where the registered bit is cleared but the guc_id is not
yet freed.
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 99d8c807ff056..e90304e5b9554 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -3323,8 +3323,15 @@ int xe_guc_deregister_done_handler(struct xe_guc *guc, u32 *msg, u32 len)
> if (unlikely(!q))
> return -EPROTO;
>
> - if (!exec_queue_destroyed(q) || exec_queue_pending_disable(q) ||
> - exec_queue_pending_enable(q) || exec_queue_enabled(q)) {
> + /*
> + * The registered bit is cleared by the first deregister-done, but the
> + * guc_id is only freed once the deferred destroy work has run, so the
> + * lookup above still resolves in between. Checking it here makes a
> + * duplicate notification an error rather than a second destroy.
> + */
> + if (!exec_queue_registered(q) || !exec_queue_destroyed(q) ||
[Severity: High]
This isn't a bug introduced by this patch, but this added check may trigger
a use-after-free in certain timing conditions.
The queue is loaded from the XArray locklessly and without taking a reference
count in drivers/gpu/drm/xe/xe_guc_submit.c:g2h_exec_queue_lookup:
drivers/gpu/drm/xe/xe_guc_submit.c:g2h_exec_queue_lookup() {
...
q = xa_load(&guc->submission_state.exec_queue_lookup, guc_id);
...
}
If a duplicate DEREGISTER_DONE G2H message arrives just as the asynchronous
destroy worker (__guc_exec_queue_destroy_async) is tearing down the
xe_exec_queue, the G2H worker can grab a pointer to q just before the destroy
worker calls xa_erase.
Because the lookup does not increment a reference count, and the object is
freed via kfree in __xe_exec_queue_free without waiting for RCU grace periods,
could exec_queue_registered(q) end up dereferencing a freed pointer?
> + exec_queue_pending_disable(q) || exec_queue_pending_enable(q) ||
> + exec_queue_enabled(q)) {
> xe_gt_err(guc_to_gt(guc),
> "DEREGISTER_DONE: Unexpected engine state 0x%04x, guc_id=%d",
> atomic_read(&q->guc->state), q->guc->id);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908231854.1218934-4-umesh.nerlige.ramappa@intel.com?part=1
next prev parent reply other threads:[~2026-09-08 23:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 23:18 [PATCH 0/2] Some error handling improvements in GuC Umesh Nerlige Ramappa
2026-09-08 23:18 ` [PATCH 1/2] drm/xe/guc: Reject a duplicate deregister-done G2H Umesh Nerlige Ramappa
2026-09-08 23:32 ` sashiko-bot [this message]
2026-09-08 23:18 ` [PATCH 2/2] drm/xe/guc: Sanity check GuC-reported hwconfig table size Umesh Nerlige Ramappa
2026-09-08 23:26 ` sashiko-bot
2026-09-08 23:26 ` ✗ CI.checkpatch: warning for Some error handling improvements in GuC Patchwork
2026-09-08 23:28 ` ✓ CI.KUnit: success " Patchwork
2026-09-09 0:14 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-09 8:17 ` ✗ 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=20260908233245.E6BB71F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=umesh.nerlige.ramappa@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.