Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniele Ceraolo Spurio" <daniele.ceraolospurio@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/i915/pxp: access the component data under lock when sending IO messages
Date: Mon, 30 Nov 2026 22:15:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-242092@kernel.org> (raw)
In-Reply-To: <20261130220020.278579-5-daniele.ceraolospurio@intel.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/i915/pxp: unlocked pxp_component read before locking
  tee_mutex [1]
--

commit 42cfbb60a511aa2cd5a38a2e1ac5e01feec04a77
Author: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

drm/i915/pxp: access the component data under lock when sending IO messages

This commit moves the read of pxp->pxp_component inside pxp->tee_mutex in
intel_pxp_tee_io_message() to avoid racing with component unbind.

> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
> index 1784153f0cf85..a42b786b56126 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
> @@ -61,11 +61,13 @@ static int intel_pxp_tee_io_message(struct intel_pxp *pxp,
>  				    u32 *msg_out_rcv_size)
>  {
>  	struct drm_i915_private *i915 = pxp->ctrl_gt->i915;
> -	struct i915_pxp_component *pxp_component = pxp->pxp_component;
> +	struct i915_pxp_component *pxp_component;
>  	int ret = 0;
>  
>  	mutex_lock(&pxp->tee_mutex);
>  
> +	pxp_component = pxp->pxp_component;
> +
>  	/*
>  	 * The binding of the component is asynchronous from i915 probe, so we
>  	 * can't be sure it has happened.

[Severity: Critical]
This problem wasn't introduced by this patch, but does
intel_pxp_tee_stream_message() have the same unlocked pxp->pxp_component
read [1] before acquiring pxp->tee_mutex?

drivers/gpu/drm/i915/pxp/intel_pxp_tee.c:intel_pxp_tee_stream_message() {
    ...
	struct i915_pxp_component *pxp_component = pxp->pxp_component;
	unsigned int offset = 0;
	struct scatterlist *sg;
	int ret;

	if (msg_in_len > max_msg_size || msg_out_len > max_msg_size)
		return -ENOSPC;

	mutex_lock(&pxp->tee_mutex);

	if (unlikely(!pxp_component || !pxp_component->ops->gsc_command)) {
    ...
}

If mei_pxp_remove() unbinds the component and frees comp_master after
pxp_component is read on entry to intel_pxp_tee_stream_message() but
before pxp->tee_mutex is locked, intel_pxp_tee_stream_message() checks the
stale local pointer and dereferences freed memory when calling
pxp_component->ops->gsc_command():

CPU0                                  CPU1
                                      intel_pxp_tee_stream_message()
                                        pxp_component = pxp->pxp_component;
mei_pxp_remove()
  component_master_del()
    i915_pxp_tee_component_unbind()
      mutex_lock(&pxp->tee_mutex);
      pxp->pxp_component = NULL;
      mutex_unlock(&pxp->tee_mutex);
  kfree(comp_master);
                                        mutex_lock(&pxp->tee_mutex);
                                        if (!pxp_component || ...)
                                        pxp_component->ops->gsc_command(...)
                                          <-- use-after-free

[1] https://sashiko.dev/#/bug/linux-af0f5760-e7bb-43e3-9b35-d6b6f63dcfde

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130220020.278579-4-daniele.ceraolospurio@intel.com?part=1

  reply	other threads:[~2026-11-30 22:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 22:00 [PATCH 0/2] Only access the PXP component pointer under lock Daniele Ceraolo Spurio
2026-11-30 22:00 ` [PATCH 1/2] drm/i915/pxp: access the component data under lock when sending IO messages Daniele Ceraolo Spurio
2026-11-30 22:15   ` sashiko-bot [this message]
2026-11-30 22:41   ` Rodrigo Vivi
2026-11-30 22:47     ` Ceraolo Spurio, Daniele
2026-11-30 22:55       ` Rodrigo Vivi
2026-11-30 22:00 ` [PATCH 2/2] drm/i915/pxp: access the component data under lock when sending stream messages Daniele Ceraolo Spurio
2026-12-01  0:29 ` ✓ i915.CI.BAT: success for Only access the PXP component pointer under lock 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-242092@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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