Intel-XE Archive on 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 v4 2/3] drm/xe/guc: Protect timeout handling from device unplug
Date: Fri, 09 Oct 2026 15:14:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-165753@kernel.org> (raw)
In-Reply-To: <20261009145906.886719-7-satyanarayana.k.v.p@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/xe: UAF in scheduler timer due to NO_HANG return during unplug
--

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

drm/xe/guc: Protect timeout handling from device unplug

This commit guards the GuC scheduler timeout callback with drm_dev_enter()
and drm_dev_exit() to handle device unplug. If the device is unplugged,
it marks the job with -ENODEV and returns DRM_GPU_SCHED_STAT_NO_HANG.

> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 0b231228bde8b..443842e87498e 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -1599,6 +1599,12 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job)
>  	int err = -ETIME;
>  	pid_t pid = -1;
>  	bool wedged = false, wedge_device = false, skip_timeout_check;
> +	int idx;
> +
> +	if (!drm_dev_enter(&xe->drm, &idx)) {
> +		xe_sched_job_set_error(job, -ENODEV);
> +		return DRM_GPU_SCHED_STAT_NO_HANG;

[Severity: High]
Does returning DRM_GPU_SCHED_STAT_NO_HANG here during device unplug cause a
use-after-free in the scheduler timer?

When the unplug path calls drm_sched_fini(), it stops queues and waits on
cancel_delayed_work_sync(&sched->work_tdr). Concurrently, returning
DRM_GPU_SCHED_STAT_NO_HANG from the timeout handler instructs the scheduler
to reinsert the job onto pending_list and call
drm_sched_start_timeout_unlocked().

Because pending_list is not empty, drm_sched_start_timeout_unlocked()
re-arms work_tdr via mod_delayed_work().

Once the timeout handler returns, cancel_delayed_work_sync() completes, but
the timer remains actively armed. After drm_sched_fini() finishes and devm
frees the scheduler, the armed timer fires, causing a panic.

Should this return DRM_GPU_SCHED_STAT_ENODEV instead to prevent re-arming
the timer?

> +	}
>  
>  	xe_gt_assert(guc_to_gt(guc), !exec_queue_destroyed(q));

[ ... ]

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

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

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 14:59 [PATCH v4 0/3] Fix kernel crash during driver teardown Satyanarayana K V P
2026-10-09 14:59 ` [PATCH v4 1/3] drm/xe: Prevent VF memory IRQ from accessing a torn-down engine Satyanarayana K V P
2026-10-09 14:59 ` [PATCH v4 2/3] drm/xe/guc: Protect timeout handling from device unplug Satyanarayana K V P
2026-10-09 15:14   ` sashiko-bot [this message]
2026-10-09 14:59 ` [PATCH v4 3/3] drm/xe/gt: Disable GT reset worker before engine teardown Satyanarayana K V P
2026-10-09 15:07 ` ✓ CI.KUnit: success for Fix kernel crash during driver teardown (rev4) Patchwork
2026-10-09 16:27 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-10-09 19:59 ` ✗ Xe.CI.FULL: " 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-165753@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